7 Replies Latest reply on Aug 29, 2014 10:16 AM by Maximos Sapranidis

    Weld Picketlink Atmosphere

    Maximos Sapranidis Newbie

      Hello,

       

      I have a JEE application secured by Picketlink (using deltaspike) and deployed to wildfly 8.1 final.

      I was able to integrate with Atmosphere and create a simple chat based on the Jersey chat example (using @AtmosphereService annotation).

      I am now facing the following issue:

       

      I am already using picketlink to handle all my authentication/security needs on the Rest service but when I try to integrate the authentication annotations to the Atmosphere service I am getting the following exception:

      "org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped"

      This should not be the case since the actual service is a Rest endpoint on which the initial call is done when a socket is originally opened.

      The link for the project is this one maxsap/antitheft at atmosphere · GitHub

      Stateless Identity is request scoped, I have also tried state-full which is session scoped but the same error occurs with the only difference that the scope type is different.

       

      I have posted this question to Atmosphere's support forum but the feedback was to post this here since this looks like a weld issue.

       

      Best,

       

      Maximos.

        • 1. Re: Weld Picketlink Atmosphere
          Martin Kouba Master

          Hi Maximos,

          could you post the full stack trace? Anyway, we already encountered some problems with atmosphere long running requests, see for example https://issues.jboss.org/browse/WFLY-1533.

          • 2. Re: Re: Weld Picketlink Atmosphere
            Maximos Sapranidis Newbie

            Hello Martin,

            Sorry for the late response, this was quite tricky since the actual stack trace was hidden under atmospheres exception.

            The error got is:

            AtmosphereResourceEventImpl{ isCancelled=false isClosedByClient=false isClosedByApplication=false isResumedOnTimeout=false throwable=org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped resource=adb90eb9-58b4-4f4b-9c2d-7d2fb9ea10b6}

             

            And the stacktrace:

             

            16:28:22,706 ERROR [stderr] (default task-9) org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
            
            
            16:28:22,707 ERROR [stderr] (default task-9) at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680)
            
            
            16:28:22,707 ERROR [stderr] (default task-9) at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:79)
            
            
            16:28:22,707 ERROR [stderr] (default task-9) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78)
            
            
            16:28:22,707 ERROR [stderr] (default task-9) at org.picketlink.internal.DefaultStatelessIdentity$Proxy$_$$_WeldClientProxy.isLoggedIn(Unknown Source)
            
            
            16:28:22,708 ERROR [stderr] (default task-9) at com.gr.project.security.service.SecuredListener.onConnect(SecuredListener.java:69)
            
            
            16:28:22,708 ERROR [stderr] (default task-9) at org.atmosphere.websocket.DefaultWebSocketProcessor.notifyListener(DefaultWebSocketProcessor.java:707)
            
            
            16:28:22,708 ERROR [stderr] (default task-9) at org.atmosphere.websocket.DefaultWebSocketProcessor.open(DefaultWebSocketProcessor.java:242)
            
            
            16:28:22,708 ERROR [stderr] (default task-9) at org.atmosphere.container.JSR356Endpoint.onOpen(JSR356Endpoint.java:185)
            
            
            16:28:22,708 ERROR [stderr] (default task-9) at io.undertow.websockets.jsr.EndpointSessionHandler.onConnect(EndpointSessionHandler.java:70)
            
            
            16:28:22,709 ERROR [stderr] (default task-9) at io.undertow.websockets.jsr.JsrWebSocketFilter$1.handleUpgrade(JsrWebSocketFilter.java:115)
            
            
            16:28:22,709 ERROR [stderr] (default task-9) at io.undertow.server.protocol.http.HttpReadListener.exchangeComplete(HttpReadListener.java:228)
            
            
            16:28:22,709 ERROR [stderr] (default task-9) at io.undertow.server.protocol.http.HttpServerConnection.exchangeComplete(HttpServerConnection.java:218)
            
            
            16:28:22,709 ERROR [stderr] (default task-9) at io.undertow.server.HttpServerExchange.invokeExchangeCompleteListeners(HttpServerExchange.java:1028)
            
            
            16:28:22,709 ERROR [stderr] (default task-9) at io.undertow.server.HttpServerExchange.terminateResponse(HttpServerExchange.java:1245)
            
            
            16:28:22,710 ERROR [stderr] (default task-9) at io.undertow.server.Connectors.terminateResponse(Connectors.java:69)
            
            
            16:28:22,710 ERROR [stderr] (default task-9) at io.undertow.server.protocol.http.ServerFixedLengthStreamSinkConduit.channelFinished(ServerFixedLengthStreamSinkConduit.java:33)
            
            
            16:28:22,710 ERROR [stderr] (default task-9) at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.exitFlush(AbstractFixedLengthStreamSinkConduit.java:249)
            
            
            16:28:22,710 ERROR [stderr] (default task-9) at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:183)
            
            
            16:28:22,710 ERROR [stderr] (default task-9) at org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
            
            
            16:28:22,710 ERROR [stderr] (default task-9) at io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:99)
            
            
            16:28:22,711 ERROR [stderr] (default task-9) at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
            
            
            16:28:22,711 ERROR [stderr] (default task-9) at io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:619)
            
            
            16:28:22,711 ERROR [stderr] (default task-9) at io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:527)
            
            
            16:28:22,711 ERROR [stderr] (default task-9) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
            
            
            16:28:22,711 ERROR [stderr] (default task-9) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
            
            
            16:28:22,712 ERROR [stderr] (default task-9) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
            
            
            16:28:22,712 ERROR [stderr] (default task-9) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
            
            
            16:28:22,712 ERROR [stderr] (default task-9) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:164)
            
            
            16:28:22,712 ERROR [stderr] (default task-9) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:654)
            
            
            16:28:22,712 ERROR [stderr] (default task-9) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
            
            
            16:28:22,713 ERROR [stderr] (default task-9) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
            
            
            16:28:22,713 ERROR [stderr] (default task-9) at java.lang.Thread.run(Thread.java:724)
            

             

            Hope that helps.

            Best,

             

            Maximos.

            • 3. Re: Re: Weld Picketlink Atmosphere
              Martin Kouba Master

              Maybe the problem is that the Atmosphere listener is invoked after the upgrade is performed and the original request is terminated. Try to enable debug/trace logging for Weld (see http://weld.cdi-spec.org/documentation/#7) and watch the "Destroying request..." message (at this time the request context is deactivated).

              • 4. Re: Re: Weld Picketlink Atmosphere
                Maximos Sapranidis Newbie

                Hello Martin, I have tried setting the correct log level and searching for "Disconnect". Unfortunately there doesn't seem to be any such entry in the logs.

                This is the link of my logs http://pastebin.com/6DmA9kcN

                The only thing that I think might be useful is:

                2014-08-09 21:27:09,103 DEBUG [org.jboss.weld.Conversation] (default task-2) WELD-000327: Resuming conversation with id null

                 

                Best,

                 

                Maximos.

                • 5. Re: Re: Weld Picketlink Atmosphere
                  Martin Kouba Master

                  Hi Maximos, I thought you're deploying the application to WildFly 8.1 but the log shows "WildFly 8.0.0.CR1" (note that CR1 is shipped with Weld 2.0.x whereas Final and 8.1 contain Weld 2.1.x). "Resuming conversation with id null" messages can be safely ignored. Anyway, set the log level for "org.jboss.weld" category to TRACE in order to see the aforementioned messages (initializing/destroying request).

                  • 6. Re: Re: Weld Picketlink Atmosphere
                    Maximos Sapranidis Newbie

                    Sorry there was a mixup on the with the local servers.

                    I have deployed on 8.1 final heres the logs: http://pastebin.com/8mDpcSYR

                    Indeed I can think that the context gets destroyed for some reason :

                    2014-08-16 21:44:29,038 TRACE [org.jboss.weld.Context] (default task-33) WELD-000201: Context org.jboss.weld.context.beanstore.http.RequestBeanStore@7f222cfe cleared

                    2014-08-16 21:44:29,038 TRACE [org.jboss.weld.Context] (default task-33) WELD-000215: Bean store org.jboss.weld.context.beanstore.http.LazySessionBeanStore@402dcdcc is detached

                    2014-08-16 21:44:29,942 TRACE [org.jboss.weld.Servlet] (default task-34) WELD-000708: Initializing request io.undertow.servlet.spec.HttpServletRequestImpl@7c7ad0d2

                    2014-08-16 21:44:29,942 TRACE [org.jboss.weld.Context] (default task-34) WELD-000222: Loading bean store org.jboss.weld.context.beanstore.http.LazySessionBeanStore@6323cad6 map from session null

                    2014-08-16 21:44:29,943 TRACE [org.jboss.weld.Servlet] (default task-34) WELD-000709: Destroying request io.undertow.servlet.spec.HttpServletRequestImpl@7c7ad0d2

                    2014-08-16 21:44:29,943 TRACE [org.jboss.weld.Context] (default task-34) WELD-000215: Bean store org.jboss.weld.context.beanstore.http.RequestBeanStore@6c94d64e is detached

                    2014-08-16 21:44:29,943 TRACE [org.jboss.weld.Context] (default task-34) WELD-000201: Context org.jboss.weld.context.http.HttpRequestContextImpl@290a9f4c cleared

                    2014-08-16 21:44:29,943 TRACE [org.jboss.weld.Context] (default task-34) WELD-000201: Context org.jboss.weld.context.beanstore.http.RequestBeanStore@6c94d64e cleared

                    2014-08-16 21:44:29,943 TRACE [org.jboss.weld.Context] (default task-34) WELD-000215: Bean store org.jboss.weld.context.beanstore.http.LazySessionBeanStore@6323cad6 is detached

                    2014-08-16 21:44:29,944 TRACE [org.atmosphere.cdi.CDIObjectFactory] (default task-34) Unable to find org.atmosphere.cpr.AtmosphereResourceImpl. Creating the object directly.

                    2014-08-16 21:44:29,944 TRACE [org.atmosphere.cpr.AtmosphereFramework] (default task-34) Query String translated to headers {X-Atmosphere-Transport=websocket, X-Atmosphere-Framework=2.2.3-jquery, X-Atmosphere-TrackMessageSize=true, Content-Type=application/json, X-atmo-protocol=true, X-Atmosphere-tracking-id=0}

                     

                    Best,

                    Maximos.

                    • 7. Re: Weld Picketlink Atmosphere
                      Maximos Sapranidis Newbie

                      Any updates on this issue?

                      Is this an issue with weld after all?

                       

                      Best,

                      Maximos.