-
Bug
-
Resolution: Done
-
Major
-
1.7.5.SP1.GA
-
False
-
False
-
+
-
Undefined
-
Workaround Exists
-
-
-
---
-
CDI specification[1] defines HttpSession as one of the supported additional built-in beans. However, when an application has an injection of HttpSession like the following code[2] and runs with `./mvnw compile quarkus:dev`, Quarkus throws UnsatisfiedResolutionException with the following stacktrace[3] during the build phase.
An injection of HttpServletRequest, HttpServletResponse, or ServletContext works fine, so it appears that only support for injection of HttpSession is currently missing.
[1] https://jakarta.ee/specifications/cdi/2.0/cdi-spec-2.0.html#additional_builtin_beans
A servlet container must provide the following built-in beans, all of which have qualifier @Default:
- a bean with bean type javax.servlet.http.HttpServletRequest, allowing injection of a reference to the HttpServletRequest
- a bean with bean type javax.servlet.http.HttpSession, allowing injection of a reference to the HttpSession,
- a bean with bean type javax.servlet.ServletContext, allowing injection of a reference to the ServletContext,
[2] example code
@Path("/hello") public class GreetingResource { @Inject public HttpSession session; @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { System.out.println("# session.getId()=" + session.getId()); return "hello"; } }
[3] UnsatisfiedResolutionException happens during the build phase
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.7.5.Final-redhat-00011:build (default) on project getting-started: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [ERROR] [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.servlet.http.HttpSession and qualifiers [@Default] [ERROR] - java member: org.acme.quickstart.GreetingResource#session [ERROR] - declared on CLASS bean [types=[org.acme.quickstart.GreetingResource, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.quickstart.GreetingResource] [ERROR] at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:990) [ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:234) [ERROR] at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:122) [ERROR] at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:391) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566) [ERROR] at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932) [ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:277) [ERROR] at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [ERROR] at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578) [ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) [ERROR] at java.base/java.lang.Thread.run(Thread.java:834) [ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:479) [ERROR] Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.servlet.http.HttpSession and qualifiers [@Default] [ERROR] - java member: org.acme.quickstart.GreetingResource#session [ERROR] - declared on CLASS bean [types=[org.acme.quickstart.GreetingResource, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.quickstart.GreetingResource] [ERROR] at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:494) [ERROR] at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:362) [ERROR] at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:226) [ERROR] ... 14 more [ERROR] -> [Help 1]