[ https://issues.apache.org/jira/browse/MYFACES-4299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16893433#comment-16893433 ]
Thomas Andraschko commented on MYFACES-4299: -------------------------------------------- Can replicate it in Tomcat. I would say that a WebSocket connection doesnt go through the FacesServlet -> therefore no FacesContext should be active. If there is no FacesContext, the ManagedPropertyProducer wont work. Maybe the ManagedPropertyProducer can fallback to the beanManager instead FacesContext. In your case i would just remove the @ManagedProperty and it will work fine. > ManagedProperty & Websocket: NullPointerException > -------------------------------------------------- > > Key: MYFACES-4299 > URL: https://issues.apache.org/jira/browse/MYFACES-4299 > Project: MyFaces Core > Issue Type: Bug > Components: JSR-372 > Affects Versions: 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4 > Environment: Tomcat > Reporter: Volodymyr Siedlecki > Priority: Minor > Attachments: MYFACES-4299-app.zip > > > Hello, > > I have a sample JSF 2.3.3 application that uses @ManagedProperty with a web > socket observer class. This application throws a null pointer exception. > In the createManagedProperty of the ManagedPropertyProducer class, > FacesContext.getCurrentInstance() returns null. > In the createManagedProperty method, if you catch the error and create a new > facesContext via BeanProvider.getContextualReference, the example still won’t > work. Is there any way around this error? > Or can anyone confirm that this example is not a valid use of > ManagedProperty? It doesn’t seem like it since the communication is going > through web sockets and therefore isn’t hitting the Faces Servlet. > > Also, this application doesn't work with the mojarra 2.3 code either. > > I’ve provided the sample application. > Here is the stack trace: > java.lang.NullPointerException > at > org.apache.myfaces.cdi.managedproperty.ManagedPropertyProducer.createManagedProperty(ManagedPropertyProducer.java:83) > at > org.apache.myfaces.cdi.managedproperty.ManagedPropertyProducer.lambda$new$0(ManagedPropertyProducer.java:77) > at > org.apache.myfaces.cdi.util.AbstractDynamicProducer.create(AbstractDynamicProducer.java:97) > at > org.apache.webbeans.component.third.ThirdpartyBeanImpl.create(ThirdpartyBeanImpl.java:97) > at > org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68) > at > org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125) > at > org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:813) > at > org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:673) > > Thank you -- This message was sent by Atlassian JIRA (v7.6.14#76016)