In a web application, users use a servlet HTTP session. Some data are stored in CDI @SessionScoped beans. Later in some pages WebSocket communications are performed between the user browser and the server.
With GlassFish 4, when using an injected @SessionScoped CDI bean from a WebSocket @ServerEndpoint with GlassFish 4.0 I get an error message: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped
From JSP/servlet type requests, using the @SessionScoped CDI bean is fine, but not from the WebSocket @ServerEndpoint.
Also note that using @Singleton CDI beans from the @ServerEndpoint works fine, so this is not a general purpose dependency injection problem.
Maybe I did something wrong.
So my questions is can @SessionScoped CDI beans be used from methods of WebSocket @ServerEndpoint beans? If yes, how?
Thank you for your time.