It compiles without errors. And when doing localhost:8080/hello1 it prints "hello1". However, when going localhost:8080/hello2, then it throws a NullPointerException:
2024-03-03 13:02:02,575 ERROR [io.und.req.io] (executor-thread-2) Exception handling request 0efe619a-ccc2-4031-8d17-5c8555ea55ce-1 to /api/hello2: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException: Cannot invoke "jakarta.ws.rs.sse.Sse.getClass()" because "this.sse" is null
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:107)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:344)
The NullPointerException is thrown because this bean did not invoke constructor injection (but instead created this bean with a null-argument constructor generated by Quarkus). Secondly, the @PostConstruct method wasn't called either.
Expected behavior
Constructor injection (of @Singleton or @ApplicationScoped beans) should work and the @PostConstruct method should also be called.
Actual behavior
Constructor injection (of @Singleton or @ApplicationScoped beans) does not work and the @PostConstruct method is also not called.
How to Reproduce?
compile the class above and run it
look at the console (no logs defined within the constructor injection and @PostConstructmethod are called)
go to localhost:8080/hello1 (it works)
go to localhost:8080/hello2 (throws NPE)
Output of uname -a or ver
No response
Output of java -version
openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment (build 21.0.2+13-58) OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)
Quarkus version or git rev
3.8.1
Build tool (ie. output of mvnw --version or gradlew --version)
No response
Additional information
Even if this class is annotated with @Singleton, I suppose the same issue will also happen with @ApplicationScoped beans.
Describe the bug
I have this Rest endpoint:
It compiles without errors. And when doing
localhost:8080/hello1
it prints "hello1". However, when goinglocalhost:8080/hello2
, then it throws a NullPointerException:The NullPointerException is thrown because this bean did not invoke constructor injection (but instead created this bean with a null-argument constructor generated by Quarkus). Secondly, the
@PostConstruct
method wasn't called either.Expected behavior
Constructor injection (of
@Singleton
or@ApplicationScoped
beans) should work and the@PostConstruct
method should also be called.Actual behavior
Constructor injection (of
@Singleton
or@ApplicationScoped
beans) does not work and the@PostConstruct
method is also not called.How to Reproduce?
@PostConstruct
method are called)localhost:8080/hello1
(it works)localhost:8080/hello2
(throws NPE)Output of
uname -a
orver
No response
Output of
java -version
openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment (build 21.0.2+13-58) OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)
Quarkus version or git rev
3.8.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
Even if this class is annotated with
@Singleton
, I suppose the same issue will also happen with@ApplicationScoped
beans.