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

java.lang.NoSuchFieldException when MyFaces and Mojarra are on the classpath

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0-beta-3
    • 2.0.0-beta-3
    • JSR-314
    • None
    • GlassFish v3

    Description

      When starting MyFaces with the appropriate configurations in GlassFish's sun-web.xml, everything functions properly except for this ugly Exception at startup:

      SCHWERWIEGEND: Cannot find private field _firstInstance from ExternalContext
      java.lang.NoSuchFieldException: _firstInstance
      at java.lang.Class.getDeclaredField(Class.java:1882)
      at org.apache.myfaces.context.FacesContextFactoryImpl.<init>(FacesContextFactoryImpl.java:81)

      This is caused because MyFaces provides this field in its implementation of javax.faces.context.ExternalContext, but Mojarra does not. And althought we set the right configuration parameters for using MyFaces, GlassFish wants to use Mojarra's version of this class when accessing the field via reflection.

      The solution to this is very easy. We just have to store _firstInstance in a package private class with a specific name (_MyFacesExternalContextHelper) so we won't run into any classloading problems.

      Attachments

        Activity

          People

            jakobkorherr Jakob Korherr
            jakobkorherr Jakob Korherr
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: