9 Replies Latest reply on Aug 3, 2015 12:56 PM by Mallikarjuna Reddy Nune

    facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices

    Mallikarjuna Reddy Nune Newbie

      We are migrating from Jboss5.1EAP to wildfly8.2, our applications deployment structure looks like product1.ear/product2.war and apart from these few webservices

      Seems deployment is successful ,able to invoke application successfully but when trying to access any webservice facing below error .

       

       

      2015-07-24 05:47:11,089 ERROR [io.undertow.request] (default task-24) UT005023: Exception handling request to /ourwebservice/request/parameters : 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.ca.iamframework.webservices.api.ManagedObjectResource$Proxy$_$$_WeldClientProxy.getManagedObjectByUniqueAttribute(Unknown Source) [webservices.jar:]

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

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

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

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

       

      From the forums tried @ApplicationScoped too didnt worked out  facing other .

       

      Kindly suggest how to solve these errors

       

       

      Regards,

      Mallikarjuna

        • 2. Re: facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices
          Wolfgang Mayer Master

          Maybe you can post the source code of your web service.

          But according to JSR-000224 - Java API for XML-Based Web Serv ices @ApplicationScoped should work.

          • 3. Re: facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices
            Tomaz Cerar Master

            Wolfgang Mayer wrote:

             

            Maybe you can post the source code of your web service.

            But according to JSR-000224 - Java API for XML-Based Web Serv ices @ApplicationScoped should work.

            nah, EAP 5 didn't have CDI yet, in EE7 cdi is enabled by default. My guess is that deployment doesn't use or doesn't CDI itself, so disabling it or at least not have it enabled for all beans should solve the issue.

            • 4. Re: facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices
              Mallikarjuna Reddy Nune Newbie

              Hi,

               

              Thanks for the reply,

               

              sourcecode of our webservices looks like below

               

              @Path("{envalias}/mo/{objecttype}")

              public class ManagedeoBJtends BaseRes {

                  private static final Logger logger = Logger.getLogger("webservice mo");

               

               

                  // Flag to enable synchronize user on a task submission

                  @HeaderParam("Sync-User") String syncUser;

                  // Flag to enable synchronize user with accounts on a task submission

                  @HeaderParam("Sync-Accounts") String syncAccounts;

               

               

                  /**

                   * Create a managed object

                   * @param moRequestData

                   * @return

                   * @throws Exception

                   */

                  @POST

                  @Consumes({"application/json"})

                  @Produces({"application/json"})

                  public Response createManagedObject(ManagedObjectRequest moRequestData) throws Exception {

              //business logic

              }

               

              when I tried using @pplicationScoped facing below error

               

              2015-07-28 01:57:28,169 SEVERE [com.sun.jersey.spi.container.ContainerResponse] (default task-1) The RuntimeException could not be mapped to a response, re-throwing to the HTTP container: java.lang.RuntimeException: It is illegal to inject a @HeaderParam into a singleton

                at org.jboss.resteasy.core.HeaderParamInjector.inject(HeaderParamInjector.java:33) [resteasy-jaxrs-3.0.10.Final.jar:]

                at org.jboss.resteasy.core.PropertyInjectorImpl.inject(PropertyInjectorImpl.java:159) [resteasy-jaxrs-3.0.10.Final.jar:]

                at org.jboss.resteasy.cdi.JaxrsInjectionTarget.inject(JaxrsInjectionTarget.java:62) [resteasy-cdi-3.0.10.Final.jar:]

                at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:150) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]

                at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]

                at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:98) [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]

               

               

              Regards,

              Mallikarjuna

              • 5. Re: facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices
                Mallikarjuna Reddy Nune Newbie

                Also tried disabling weld ,

                not able to deploy applciation properly facing below issues

                 

                New missing/unsatisfied dependencies:

                service jboss.deployment.subunit.main_proj.ear"."management_console.war".deploymentCompleteService (missing) dependents: [service jboss.deployment.subunit."main_proj.ear"."main_pror_mainproj_ejb.jar".INSTALL]

                      service jboss.deployment.subunit."main_pror.ear"."policyinfo.rar".deploymentCompleteService (missing) dependents: [service jboss.deployment.subunit."main_pror.ear"."info.rar".INSTALL]

                      service jboss.deployment.subunit."main_pro.ear"."user_consoleinfo.war".INSTALL (missing) dependents: [service jboss.deployment.subunit."main_pro.ear"."management_console.war".INSTALL]

                • 7. Re: facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices
                  Mallikarjuna Reddy Nune Newbie

                  Hi,

                   

                  Modified jboss-deployment-structure.xml as below,

                  <dependencies>

                           <!-- Manually add all JEE6-apis except the javax.ws.rs.api, javax.json.api -->

                           <module name="javax.activation.api" export="true" />

                           <module name="javax.annotation.api" export="true" />

                           <module name="javax.batch.api" export="true" />

                           <module name="javax.ejb.api" export="true" />

                           <module name="javax.el.api" export="true" />

                           <module name="javax.enterprise.api" export="true" />

                           <module name="javax.enterprise.concurrent.api" export="true" />

                           <module name="javax.inject.api" export="true" />

                           <module name="javax.interceptor.api" export="true" />

                           <module name="javax.jms.api" export="true" />

                           <module name="javax.jws.api" export="true" />

                           <module name="javax.mail.api" export="true" />

                           <module name="javax.management.j2ee.api" export="true" />

                           <module name="javax.persistence.api" export="true" />

                           <module name="javax.resource.api" export="true" />

                           <module name="javax.rmi.api" export="true" />

                           <module name="javax.security.auth.message.api"

                               export="true" />

                           <module name="javax.security.jacc.api" export="true" />

                           <module name="javax.servlet.api" export="true" />

                           <module name="javax.servlet.jsp.api" export="true" />

                           <module name="javax.transaction.api" export="true" />

                           <module name="javax.validation.api" export="true" />

                           <!-- <module name="javax.ws.rs.api" export="true" services="export"/> -->

                           <module name="javax.xml.bind.api" export="true" />

                           <module name="javax.xml.soap.api" export="true" />

                           <module name="javax.xml.ws.api" export="true" />

                           <!-- This one always goes last. -->

                           <module name="javax.api" export="true" />

                          

                          </dependencies>

                   

                  with this able to deploy webservices successfully, But facing below error when trying to access application(not webservices)

                   

                  2015-07-29 11:39:11,206 ERROR [io.undertow.request] (default task-6) UT005023: Exception handling request to /test/my_app/login.jsp: java.lang.RuntimeException: java.lang.NullPointerException

                    at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:184) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at com.app.webapp.authentication.FrameworkLoginFilter.doFilter(FrameworkLoginFilter.java:429) [user_console.jar:]

                    at com.app.webadmin.configuration.ui.servlet.LoginFilter.doFilter(LoginFilter.java:450) [webadmin-configuration.jar:]

                    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at com.netegrity.webapp.filter.LocaleFilter.doFilter(LocaleFilter.java:100) [user_console.jar:]

                    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at com.netegrity.webapp.filter.ClientExtractFilter.doFilter(ClientExtractFilter.java:35) [user_console.jar:]

                    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at com.netegrity.webapp.filter.SessionFilter.doFilter(SessionFilter.java:103) [user_console.jar:]

                    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_40]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_40]

                    at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]

                  Caused by: java.lang.NullPointerException

                    at org.jboss.weld.servlet.WeldCrossContextFilter.doFilter(WeldCrossContextFilter.java:63) [weld-core-impl-2.2.6.Final.jar:2014-10-03 10:05]

                    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:192) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                    at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:160) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]

                   

                  Any suggestions will be really helpful

                  • 8. Re: facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices
                    Wolfgang Mayer Master

                    Wouldn't it be easier to change to JAX-RS as suggested in the above link instead?

                    So I'd add a class that extends Application.

                     

                    @ApplicationPath("/mypath")

                     

                    public class MyApplication extends Application {

                    }

                     

                    I'd also annotate your Bean class (ManagedeoBJtends BaseRes) with @Stateless. It looks like somehow it is interpreted as a singleton.

                    • 9. Re: facing No active contexts for scope type javax.enterprise.context.RequestScoped when accessing webservices
                      Mallikarjuna Reddy Nune Newbie

                      Hi,

                       

                      Thanks for the reply,

                      But we dont want to cahnge any implementation.

                      we are using third party implementation , which generates web.xml of its own,

                      By commenting out WeldCrossContextFilter in that filter we are able to proceed without above mentioned null pointer exception .

                      kind;y let me know if this causes any security risks . Otherthan that our app is working fine with wildfly.

                       

                      Regards,

                      Mallikarjuna