MyFaces Core
  1. MyFaces Core
  2. MYFACES-2601

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


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-beta-3
    • Fix Version/s: 2.0.0-beta-3
    • Component/s: JSR-314
    • Labels:
    • Environment:
      GlassFish v3


      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(
      at org.apache.myfaces.context.FacesContextFactoryImpl.<init>(

      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.


        Jakob Korherr created issue -
        Jakob Korherr made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0-beta-3 [ 12314776 ]
        Resolution Fixed [ 1 ]
        Leonardo Uribe made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        26m 5s 1 Jakob Korherr 12/Mar/10 12:48
        Resolved Resolved Closed Closed
        55d 12h 14m 1 Leonardo Uribe 07/May/10 01:03


          • Assignee:
            Jakob Korherr
            Jakob Korherr
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: