[ 
https://issues.apache.org/jira/browse/TOMEE-947?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13668130#comment-13668130
 ] 

Romain Manni-Bucau commented on TOMEE-947:
------------------------------------------

MessageInbound contains: protected final void onTextData(Reader r) throws 
IOException {

this method prevent CDI to use any scope or proxy so @Dependent is a good 
workaround.

To get request scope and session scope we could hack 
org.apache.catalina.websocket.WebSocketServlet#doGet to store the session 
associated with the request and then use it in cdi but it has some drawbacks 
ATM:
1) will need to be redo maybe in another way for JavaEE 7
2) it can create sessions when not needed
3) session for websocket should not be http session IMO (at least not linked to 
the request because it should be closed by the websocket protocol)

Since the Expert Group didn't defined it i'd like to keep it simple and working.

Note: request scope can be workaround using deltaspike to start/stop it when 
needed
                
> Injection doesn't work in WebSocket inbound threads
> ---------------------------------------------------
>
>                 Key: TOMEE-947
>                 URL: https://issues.apache.org/jira/browse/TOMEE-947
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>         Environment: Oracle JDK 1.7.0.21, Linux i586, 
> apache-tomee-1.6.0-20130525.041140-81-jaxrs
>            Reporter: Dimitri
>         Attachments: WebSocket-CDI-Test.war, WebSocket-CDI-Test.zip
>
>
> When using Tomcat's WebSocket implementation (that means, extending 
> org.apache.catalina.websocket.WebSocketServlet), it is not possible to use 
> injection, both CDI and non-CDI, from inbound processing threads. Injecting 
> scoped and non-scoped objects simply gives null.
> Furthermore, when trying to access a session-scoped instance (OWB proxy) that 
> has already been injected into some other object, the following is written to 
> the log:
> May 26, 2013 7:57:49 PM org.apache.openejb.cdi.CdiAppContextsService 
> lazyStartSessionContext
> WARNING: Could NOT lazily initialize session context because of null 
> RequestContext

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to