4 Replies Latest reply on Jun 22, 2016 12:23 PM by James Perkins

    Can not inject HttpServletRequest object using @Context in jersey class in wildfly-8.2

    Manish Prajapati Newbie

      Hi,

       

      I am using a jersey-1.19 in wildfly-8.2 with java 7. In one of the methods of the jersey class I am trying to inject HttpServletRequest using @Context annotation.

      While accessing servet request object I am getting following error:

       

      The RuntimeException could not be mapped to a response, re-throwing to the HTTP container: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped

              at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:689) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]

              at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:79) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]

              at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]

              at com.abc.rest.api.console.PollerAPI$Proxy$_$$_WeldClientProxy.pollGetKbaQuestions(Unknown Source) [abc-ejb-0.0.1-SNAPSHOT.jar:]

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_75]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_75]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_75]

              at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_75]

              at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [jersey-server-1.19.jar:1.19]

              at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185) [jersey-server-1.19.jar:1.19]

       

      If I make my class "ApplicationScoped" then its working fine. But that doesnt make a feasible fix because I would want it to be request scoped.

       

      Can anyone guide me on what could be the root cause of the issue? as well as what might be the solution?