Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.1.15, 2.2.0-m06
    • Component/s: None
    • Labels:
      None
    • Status Whiteboard:
      Hide

      size_small importance_large

      Show
      size_small importance_large

      Description

      Google App Engine restricts access to InitialContext while Mojarra uses it for initialization.
      Here is the proposed change for WebConfiguration#canProcessJndiEntries:

      private boolean canProcessJndiEntries() {

      try

      { Util.getCurrentLoader(this).loadClass("javax.naming.InitialContext").getConstructors(); }

      catch (Throwable e) {
      if (LOGGER.isLoggable(Level.FINE))

      { LOGGER.fine( "javax.naming is unavailable. JNDI entries related to Mojarra configuration will not be processed."); }

      return false;
      }
      return true;

      }

      1. changebundle.txt
        2 kB
        Hanspeter Duennenberger

        Activity

        Hide
        yonatan added a comment -

        The above suggestion doesn't detect properly if InitialContext is available on GAE 1.5.1, since Google are using Java Agent to verify the whitelist class loading, rather than the SecurityManager.

        My suggestion is:

        com.sun.faces.config.WebConfiguration
        ... 
        private boolean canProcessJndiEntries() {
          try {
            Util.getCurrentLoader(this).loadClass("javax.naming.InitialContext").getConstructor().newInstance();
          } catch (Exception e) {
            if (LOGGER.isLoggable(Level.FINE)) {
              LOGGER.fine("javax.naming is unavailable.  JNDI entries related to Mojarra configuration will not be processed.");
            }
            return false;
          }
          return true;
        }
        ...
        
        Show
        yonatan added a comment - The above suggestion doesn't detect properly if InitialContext is available on GAE 1.5.1, since Google are using Java Agent to verify the whitelist class loading, rather than the SecurityManager. My suggestion is: com.sun.faces.config.WebConfiguration ... private boolean canProcessJndiEntries() { try { Util.getCurrentLoader( this ).loadClass( "javax.naming.InitialContext" ).getConstructor().newInstance(); } catch (Exception e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine( "javax.naming is unavailable. JNDI entries related to Mojarra configuration will not be processed." ); } return false ; } return true ; } ...
        Hide
        Ed Burns added a comment -

        Thanks for reporting this and supplying a suggested fix. GAE support is important to me personally because the website for my book is running on JSF on GAE <http://jsfcompref.com>.

        Show
        Ed Burns added a comment - Thanks for reporting this and supplying a suggested fix. GAE support is important to me personally because the website for my book is running on JSF on GAE < http://jsfcompref.com >.
        Hide
        Hanspeter Duennenberger added a comment -

        Hello.

        I'm in the middle of trying to run a JSF 2.2 (own build) app on GAE - and the solution outlined above does not work.
        GAE already complains when InitialContext class is test-loaded with an Exception:

        java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. Please see the Google App Engine developer's guide for more details.
        at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
        at com.sun.faces.config.WebConfiguration.processJndiEntries(WebConfiguration.java:687)
        at com.sun.faces.config.WebConfiguration.<init>(WebConfiguration.java:134)
        ...

        I think the best solution is outlined by http://digitaljoel.nerd-herders.com/2009/12/21/jsf-2-0-2-and-google-app-engine/ - an additional context-param to disable JNDI usage.

        Will try it and in case it works add the according changebundle here.

        Cheers
        Hanspeter

        Show
        Hanspeter Duennenberger added a comment - Hello. I'm in the middle of trying to run a JSF 2.2 (own build) app on GAE - and the solution outlined above does not work. GAE already complains when InitialContext class is test-loaded with an Exception: java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. Please see the Google App Engine developer's guide for more details. at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51) at com.sun.faces.config.WebConfiguration.processJndiEntries(WebConfiguration.java:687) at com.sun.faces.config.WebConfiguration.<init>(WebConfiguration.java:134) ... I think the best solution is outlined by http://digitaljoel.nerd-herders.com/2009/12/21/jsf-2-0-2-and-google-app-engine/ - an additional context-param to disable JNDI usage. Will try it and in case it works add the according changebundle here. Cheers Hanspeter
        Hide
        Hanspeter Duennenberger added a comment - - edited

        Added changebundle based on proposal from http://digitaljoel.nerd-herders.com/2009/12/21/jsf-2-0-2-and-google-app-engine/

        Hi Ed.

        With that change I could successfully run an application on GAE.
        I also propose this fix to be applied to the 2.0 and 2.1 branches.
        Do you agree?

        Cheers
        Hanspeter

        Show
        Hanspeter Duennenberger added a comment - - edited Added changebundle based on proposal from http://digitaljoel.nerd-herders.com/2009/12/21/jsf-2-0-2-and-google-app-engine/ Hi Ed. With that change I could successfully run an application on GAE. I also propose this fix to be applied to the 2.0 and 2.1 branches. Do you agree? Cheers Hanspeter
        Hide
        Hanspeter Duennenberger added a comment -

        disussing this on chat has lead to simpler proposal from Manfred. Also catching NoClassDefFoundException in WebConfiguration.canProcessJNDIEntries should do the trick. I'll try tomorrow and add the result then.

        Cheers
        Hanspeter

        Show
        Hanspeter Duennenberger added a comment - disussing this on chat has lead to simpler proposal from Manfred. Also catching NoClassDefFoundException in WebConfiguration.canProcessJNDIEntries should do the trick. I'll try tomorrow and add the result then. Cheers Hanspeter
        Hide
        Hanspeter Duennenberger added a comment -

        Catching NoClassDefFoundException in WebConfiguration.processJndiEntries() does work. The updated changebundle contains this change. No need for an additional context-param.
        I could successfully run GAE based JSF app locally. Unfortunately I cannot deploy to GAE from work (some proxy issue), but I'll try from home later on.

        Again, I think this should be added to trunk, 2.1- and 2.0 branch.

        Cheers
        Hanspeter

        Show
        Hanspeter Duennenberger added a comment - Catching NoClassDefFoundException in WebConfiguration.processJndiEntries() does work. The updated changebundle contains this change. No need for an additional context-param. I could successfully run GAE based JSF app locally. Unfortunately I cannot deploy to GAE from work (some proxy issue), but I'll try from home later on. Again, I think this should be added to trunk, 2.1- and 2.0 branch. Cheers Hanspeter
        Hide
        Manfred Riem added a comment -

        r=mriem

        Show
        Manfred Riem added a comment - r=mriem
        Hide
        Hanspeter Duennenberger added a comment -

        Added to trunk (2.2)

        Fixes http://java.net/jira/browse/JAVASERVERFACES-1885, r=mriem

        • catch NoClassDefFoundError thrown by GAE while trying to instantiate InitialContext

        M C:/cs/ws/mojarra_trunk/Mojarra/jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java
        Committed revision 9926

        Show
        Hanspeter Duennenberger added a comment - Added to trunk (2.2) Fixes http://java.net/jira/browse/JAVASERVERFACES-1885 , r=mriem catch NoClassDefFoundError thrown by GAE while trying to instantiate InitialContext M C:/cs/ws/mojarra_trunk/Mojarra/jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java Committed revision 9926
        Hide
        Manfred Riem added a comment -

        Can you also add the fix to the 2.1 branch?

        Show
        Manfred Riem added a comment - Can you also add the fix to the 2.1 branch?
        Hide
        Manfred Riem added a comment -

        Applied to 2.1 branch,

        commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-1885, Backported to 2.1"
        Sending jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java
        Transmitting file data ...
        Committed revision 10918.

        Show
        Manfred Riem added a comment - Applied to 2.1 branch, commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-1885 , Backported to 2.1" Sending jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java Transmitting file data ... Committed revision 10918.

          People

          • Assignee:
            Unassigned
            Reporter:
            nick_belaevski
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2 days
              2d
              Remaining:
              Remaining Estimate - 2 days
              2d
              Logged:
              Time Spent - Not Specified
              Not Specified