This is an issue when a method designated for automatic invocation at application startup is declared as a class-level method rather than an instance method, is configured to produce managed objects, or requires input arguments. Such methods will not be properly invoked during application startup.

In Java, this specifically refers to methods annotated with @Startup.

Why is this an issue?

Annotations or attributes that mark methods for execution during application startup in dependency injection frameworks have specific requirements for how these initialization methods must be declared.

When you mark a method for startup execution, the dependency injection framework generates initialization hooks that trigger the method when the application starts. For this mechanism to work correctly, the method must meet three requirements:

What is the potential impact?

When methods designated for startup execution don’t follow the required signature, the initialization logic will not execute at application startup. This can lead to:

How to fix it

Remove the static modifier from the method to make it an instance method. Ensure the method has no parameters and is not annotated with @Produces.

Code examples

Noncompliant code example

@ApplicationScoped
public class EagerAppBean {
    @Startup
    static void init() {  // Noncompliant: static method
        doSomeCoolInit();
    }
}

Compliant solution

@ApplicationScoped
public class EagerAppBean {
    @Startup
    void init() {  // Compliant: non-static, no arguments
        doSomeCoolInit();
    }
}

Resources

Documentation