Issue Details (XML | Word | Printable)

Key: JAVASERVERFACES-1885
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Unassigned
Reporter: nick_belaevski
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
javaserverfaces

GAE incompatibility in WebConfiguration class

Created: 07/Dec/10 08:28 AM   Updated: 25/Oct/12 01:43 PM   Resolved: 25/Oct/12 01:43 PM
Component/s: None
Affects Version/s: 2.0.4
Fix Version/s: 2.1.15, 2.2.0-m06

Time Tracking:
Original Estimate: 2 days
Original Estimate - 2 days
Remaining Estimate: 2 days
Remaining Estimate - 2 days
Time Spent: Not Specified
Time Spent - Not Specified

File Attachments: 1. Text File changebundle.txt (2 kB) 03/May/12 03:11 PM - Hanspeter Duennenberger


Status Whiteboard:

size_small importance_large

Tags:
Participants: Ed Burns, Hanspeter Duennenberger, Manfred Riem, nick_belaevski and yonatan


 Description  « Hide

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;

}



yonatan added a comment - 06/Aug/11 12:35 PM

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;
}
...

Ed Burns added a comment - 09/Aug/11 03:51 PM

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>.


Hanspeter Duennenberger added a comment - 27/Apr/12 01:54 PM

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


Hanspeter Duennenberger added a comment - 02/May/12 11:40 AM - 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


Hanspeter Duennenberger added a comment - 02/May/12 09:06 PM

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


Hanspeter Duennenberger added a comment - 03/May/12 08:49 AM

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


Manfred Riem added a comment - 03/May/12 03:10 PM

r=mriem


Hanspeter Duennenberger added a comment - 05/May/12 08:59 PM

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


Manfred Riem added a comment - 28/Jun/12 04:12 PM

Can you also add the fix to the 2.1 branch?


Manfred Riem added a comment - 25/Oct/12 01:42 PM

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.