2 Replies Latest reply on Aug 2, 2010 10:53 AM by Marcos Antonio

    JBoss 6 M2, M3, M4: Weld doesn't work with FORM based authentication

    Marcos Antonio Novice

      Hello, everybody!

       

      First of all, I would like to say that I've already discussed this issue in two other places:

       

      http://seamframework.org/Community/JBoss6M2WELD000702UnableToFindBeanManagerForOrgapachecatalinacoreApplicationContextFacadeb8c4f5

      (plase note that here the initial problem was another one, but it ended up with the current problem)

       

      https://jira.jboss.org/browse/WELDINT-59

       

      but as I haven't got any helpful hint in those places to solve this stubborn and mysterious problem, I came here in the hope to finally find a solution for it.

       

      The problem is simple: My web application is configured to use FORM based authentication. If I enable CDI in this application (placing beans.xml files in all modules of the application), I get this error when being redirected to the login page:

       

      2010-08-02 09:55:56,593 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/solicitacoes]] (http-127.0.0.1-8080-1) Session event listener threw exception: 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:679) [:1.0.1.SP4]
      at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:138) [:1.0.1.SP4]
      at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:100) [:1.0.1.SP4]
      at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43) [:1.0.1.SP4]
      at org.jboss.weld.servlet.HttpSessionManager_$$_javassist_25.setSession(HttpSessionManager_$$_javassist_25.java) [:1.0.1.SP4]
      at org.jboss.weld.servlet.ServletLifecycle.restoreSessionContext(ServletLifecycle.java:148) [:1.0.1.SP4]
      at org.jboss.weld.servlet.ServletLifecycle.beginSession(ServletLifecycle.java:71) [:1.0.1.SP4]
      at org.jboss.weld.servlet.WeldListener.sessionCreated(WeldListener.java:126) [:1.0.1.SP4]
      at org.apache.catalina.session.StandardSession.tellNew(StandardSession.java:367) [:6.0.0.20100721-M4]
      at org.apache.catalina.session.StandardSession.setId(StandardSession.java:341) [:6.0.0.20100721-M4]
      at org.apache.catalina.session.ManagerBase.createSession(ManagerBase.java:857) [:6.0.0.20100721-M4]
      at org.apache.catalina.session.StandardManager.createSession(StandardManager.java:291) [:6.0.0.20100721-M4]
      at org.apache.catalina.connector.Request.doGetSession(Request.java:2587) [:6.0.0.20100721-M4]
      at org.apache.catalina.connector.Request.getSessionInternal(Request.java:2458) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:231) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:559) [:6.0.0.20100721-M4]
      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.CR3]
      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.CR3]
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:93) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.20100721-M4]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.20100721-M4]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.20100721-M4]
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.20100721-M4]
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [:6.0.0.20100721-M4]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.20100721-M4]
      at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]

      2010-08-02 09:55:56,687 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/solicitacoes].[Faces Servlet]] (http-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: 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:679) [:1.0.1.SP4]
      at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:138) [:1.0.1.SP4]
      at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:100) [:1.0.1.SP4]
      at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43) [:1.0.1.SP4]
      at org.jboss.weld.servlet.HttpSessionManager_$$_javassist_25.setSession(HttpSessionManager_$$_javassist_25.java) [:1.0.1.SP4]
      at org.jboss.weld.jsf.WeldPhaseListener.initiateSessionAndConversation(WeldPhaseListener.java:168) [:1.0.1.SP4]
      at org.jboss.weld.jsf.WeldPhaseListener.beforeRestoreView(WeldPhaseListener.java:118) [:1.0.1.SP4]
      at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:87) [:1.0.1.SP4]
      at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228) [:2.0.2-FCS]
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99) [:2.0.2-FCS]
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110) [:2.0.2-FCS]
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [:2.0.2-FCS]
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [:2.0.2-FCS]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:734) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:541) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:479) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:407) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:317) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:242) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:559) [:6.0.0.20100721-M4]
      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.CR3]
      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.CR3]
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:93) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.20100721-M4]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.20100721-M4]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.20100721-M4]
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.20100721-M4]
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [:6.0.0.20100721-M4]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.20100721-M4]
      at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]

      2010-08-02 09:55:56,687 WARN  [org.apache.catalina.authenticator.FormAuthenticator] (http-127.0.0.1-8080-1) Unexpected error forwarding to login page: javax.servlet.ServletException: WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:325) [:2.0.2-FCS]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:734) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:541) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:479) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:407) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:317) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:242) [:6.0.0.20100721-M4]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:559) [:6.0.0.20100721-M4]
      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.CR3]
      at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.CR3]
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:93) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.20100721-M4]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.20100721-M4]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.20100721-M4]
      at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.20100721-M4]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.20100721-M4]
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.20100721-M4]
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [:6.0.0.20100721-M4]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.20100721-M4]
      at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]
      Caused by: 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:679) [:1.0.1.SP4]
      at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:138) [:1.0.1.SP4]
      at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:100) [:1.0.1.SP4]
      at org.jboss.weld.util.CleanableMethodHandler.invoke(CleanableMethodHandler.java:43) [:1.0.1.SP4]
      at org.jboss.weld.servlet.HttpSessionManager_$$_javassist_25.setSession(HttpSessionManager_$$_javassist_25.java) [:1.0.1.SP4]
      at org.jboss.weld.jsf.WeldPhaseListener.initiateSessionAndConversation(WeldPhaseListener.java:168) [:1.0.1.SP4]
      at org.jboss.weld.jsf.WeldPhaseListener.beforeRestoreView(WeldPhaseListener.java:118) [:1.0.1.SP4]
      at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:87) [:1.0.1.SP4]
      at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228) [:2.0.2-FCS]
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99) [:2.0.2-FCS]
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110) [:2.0.2-FCS]
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [:2.0.2-FCS]
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [:2.0.2-FCS]
      ... 23 more

       

      For the application to work, I just have to remove the beans.xml files. Now I don't know if this problem is my fault or if it is a real bug in Weld integration. I just would like to be pointed in the right direction. I'm using JBoss 6.0.0.M4, but I have this problem since JBoss 6.0.0.M2.

       

      I'm making my simple application available for you to see the problem for yourself. It is initially configured to cause the problem. Remove the beans.xml files from all modules and the problem is gone (the login page shows).

       

      Instructions:
      ------------------

       

      - Create the directory 'C:\Projeto\Java\Solicitacoes3' and unzip the zip file there.
        You can use another directory, but you'll have to change the ant build file.

      - Place the jars located in 'C:\Projeto\Java\Solicitacoes3\additional-jars' in
        <JBOSS_HOME>\common\lib.

      - Add this entry to <JBOSS_HOME>\server\default\conf\login-config.xml:
        <application-policy name="solicitacoes">
           <authentication>
              <login-module code="br.urca.solicitacoes.ejb.seguranca.ModuloLogin"
                 flag="required" />
           </authentication>
        </application-policy>

       

      - Use the ant build.xml file located in 'C:\Projeto\Java\Solicitacoes3\solicitacoes-web'
        to build and deploy the EAR file.

       

      Thank you.

       

      Marcos