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

Milan Siebenbürger commented on MYFACES-4445:
---------------------------------------------

hi Thomas,

spent some time debugging various websocket implementations and there is one 
major difference between myfaces and omnifaces/mojarra. 

It is about generating tokens for channels in different scopes - 
mojarra/omnifaces generates only one channelToken for each scope - so for 
example in the application scope there is only one channelToken for all clients 
(and this token id remains the same for page reload) (check register method in 
WebsocketChannelManager).

For this channelToken all sessions (which are closed at the right time) are 
stored - when using channelToken you always work with only one object/scope. So 
the performance issue I mentioned above does not apply to mojarra/omnifaces 
implementation.

In the myfaces implementation (if I understand it correctly) you have one 
channelToken for each web socket session - but if you close the session, the 
tokenId stays in the scope maps (a new token is generated for another user/ 
session or page reload). I am not able to judge whether the myfaces 
implementation is correct or not. I understand that any change of this would be 
difficult, and the decision would be yours to make.

 

One more thing - what do you think about this - the documentation for 
f:websocket says: "The default scope is application. When the user attribute is 
specified, then the default scope is session.". But I think in myfaces it 
fallbacks the application scope unless the developer manually specified it 
(check myfaces WebSocketComponentRenderer:131 vs. mojarra "static Scope" in 
their WebsocketChannelManager)..

 

> "No CDI container started" when using PushContext async
> -------------------------------------------------------
>
>                 Key: MYFACES-4445
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4445
>             Project: MyFaces Core
>          Issue Type: Task
>          Components: General
>    Affects Versions: 2.3-next-M7
>            Reporter: Milan Siebenbürger
>            Assignee: Thomas Andraschko
>            Priority: Minor
>             Fix For: 2.3.11, 3.0.3, 2.3-next-M8, 4.0.0-RC2
>
>
> Hello, we are trying to replace Omnifaces websockets (o:socket) with Myfaces 
> implementation in our application and we are encountering some problems that 
> prevent us from completing this task. 
>  
> 1. The most serious problem is that the MyFaces implementation does not work 
> when using asynchronous computation (Future interface). Sending a push 
> message ends with a "No CDI container started" exception, while the Omnifaces 
> implementation works flawlessly.
> {code:java}
> java.lang.IllegalStateException: No CDI container started
>         at 
> org.apache.webbeans.container.OwbCDI.getWebBeansContext(OwbCDI.java:44)
>         at org.apache.webbeans.container.OwbCDI.getBeanManager(OwbCDI.java:61)
>         at 
> org.apache.myfaces.push.cdi.PushContextImpl.send(PushContextImpl.java:64){code}
> Do you see any way to make this work, or do we have to stick with OmniFaces 
> in this situation?
>  
> 2. When using another type of push message, in response to a scheduler or jms 
> message, sending the message works, but each time it is sent, this warning 
> message is logged. 
> {code:java}
> org.apache.webbeans.web.context.WebContextsService.lazyStartSessionContext 
> Could NOT lazily initialize session context because NO active request 
> context{code}
> The reason is this part of the code in PushContextImpl:
>  
> {code:java}
> if (CDIUtils.isSessionScopeActive(beanManager)) {
>     sessionTokenBean = (WebsocketSessionBean)CDIUtils.get(beanManager, 
> WebsocketSessionBean.class, false, new Annotation[0]);
>     if (CDIUtils.isViewScopeActive(beanManager)) {
>         viewTokenBean = (WebsocketViewBean)CDIUtils.get(beanManager, 
> WebsocketViewBean.class, false, new Annotation[0]);
>     }
> }{code}
> Method isSessionScopeActive returns false (of course, because there is no 
> session scope active in this case) - it fallbacks correctly to application 
> scoped WebsocketApplicationBean, but this warning message is logged. Is there 
> any way to get rid of this log - other than reconfiguring the logging 
> framework?
> I have created a simple demonstration where you can see these problems. Just 
> download it and run it on Apache Tomcat. -> 
> https://github.com/milansie/websocket-demo
> I'd be grateful for any help or advice or, ideally, for a change in the 
> MyFaces implementation.
>  
> Thank you!
> Milan Siebenbürger
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to