Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when calling Application.isStarted because app is null #42798

Closed
ManishJain-TomTom opened this issue Aug 27, 2024 · 4 comments
Labels
kind/bug Something isn't working triage/duplicate This issue or pull request already exists

Comments

@ManishJain-TomTom
Copy link

ManishJain-TomTom commented Aug 27, 2024

Describe the bug

When trying to use the @QuarkusMain annotation with main method, the application fails to start with a NPE mentioning that the app is null.

Below is our class:

@QuarkusMain
public class Main implements QuarkusApplication {

    static Logger logger = Logger.getLogger(FlinkTestJob.class.getName());
    @Inject
    FlinkTestJob flinkTestJob;

    public static void main(String[] args) throws Exception {
        Quarkus.run(Main.class, args);
    }

    public void run() throws Exception {
        logger.info("Going to run method with FlinkTestJob: "+flinkTestJob);
        flinkTestJob.run();
    }

    @Override public int run(String... args) throws Exception {
        logger.info("Going to run method with FlinkTestJob Quarkus Run: "+flinkTestJob);
        flinkTestJob.run();

        Quarkus.waitForExit();
        return 0;
    }
}

When I run this application, I get the below error:
Exception:

Exception in thread "Shutdown thread" java.lang.NullPointerException: Cannot invoke "io.quarkus.runtime.Application.isStarted()" because "app" is null
	at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:455)

How are we running it:
We are creating a package using mvn clean install, then then using flink to run this class. Will that have an impact on the app being null?

Expected behavior

We'd be able to run the application without any problems. As we are inject FlinkTestJob in the Main class, we'd be able to call FlinkTestJob::run method.

Actual behavior

The application fails to start with exception:

Exception in thread "Shutdown thread" java.lang.NullPointerException: Cannot invoke "io.quarkus.runtime.Application.isStarted()" because "app" is null
	at io.quarkus.runtime.ApplicationLifecycleManager$ShutdownHookThread.run(ApplicationLifecycleManager.java:455)

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

openjdk version "21.0.4" 2024-07-16
OpenJDK Runtime Environment Homebrew (build 21.0.4)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.4, mixed mode, sharing)

Quarkus version or git rev

3.13.3

Build tool (ie. output of mvnw --version or gradlew --version)

mvn --version:

Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec
Java version: 21.0.4
OS name: "mac os x", version: "14.5", arch: "aarch64", family: "mac"

Additional information

We are trying to run the created jar with flink application.
Command used:
./flink run -c com.flink.Main -d flink/target/flink-stream-processor-1.0.0-SNAPSHOT-runner.jar

@ManishJain-TomTom ManishJain-TomTom added the kind/bug Something isn't working label Aug 27, 2024
@geoand
Copy link
Contributor

geoand commented Aug 28, 2024

Any chance you can share a sample application we can use to see the problem in action?

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Aug 28, 2024
@gsmet
Copy link
Member

gsmet commented Aug 28, 2024

Wonder if it could be #42794 .

@ManishJain-TomTom
Copy link
Author

Yeah, looks similar. Maybe we can close this one as a duplicate. I see that the ticket is merged into 3.14 and 3.13 main. But is it released, or will that take some more time?

@geoand geoand added triage/duplicate This issue or pull request already exists and removed triage/needs-reproducer We are waiting for a reproducer. labels Aug 28, 2024
@geoand
Copy link
Contributor

geoand commented Aug 28, 2024

Okay, let's close as a duplicate for now.

The fix is not yet part of a release, but will be soon

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants