Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4299

ManagedProperty & Websocket: NullPointerException

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4
    • 2.3-next-M1, 2.3.5
    • JSR-372
    • None
    • Tomcat

    Description

      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

      Attachments

        1. MYFACES-4299-app.zip
          11 kB
          Volodymyr Siedlecki

        Activity

          People

            tandraschko Thomas Andraschko
            volosied Volodymyr Siedlecki
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: