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

FacesConfig.getCurrentInstance and externalContext references should work before set application instance on facesContext init

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.6
    • 1.2.7
    • None
    • None

    Description

      Stack trace:

      java.lang.NullPointerException
      at org.apache.myfaces.application.ApplicationImpl.internalGetRuntimeConfig(ApplicationImpl.java:150)
      at org.apache.myfaces.application.ApplicationImpl.(ApplicationImpl.java:130)
      at org.apache.myfaces.application.ApplicationFactoryImpl.createAndLogNewApplication(ApplicationFactoryImpl.java:52)
      at org.apache.myfaces.application.ApplicationFactoryImpl.(ApplicationFactoryImpl.java:48)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at javax.faces.FactoryFinder.newFactoryInstance(FactoryFinder.java:170)
      at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:136)
      at org.apache.myfaces.context.servlet.FacesContextImpl.(FacesContextImpl.java:95)
      at org.apache.myfaces.context.servlet.FacesContextImpl.(FacesContextImpl.java:88)
      at org.apache.myfaces.context.FacesContextFactoryImpl.getFacesContext(FacesContextFactoryImpl.java:63)

      The solution is change constructor to this:

      private FacesContextImpl(final ReleaseableExternalContext externalContext)

      { _externalContext = externalContext; FacesContext.setCurrentInstance(this); //protected method, therefore must be called from here _application = ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)) .getApplication(); _renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); }

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            lu4242 Leonardo Uribe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: