My favorites | Sign in
Google
                
New issue | Search
for
| Advanced search | Search tips
Issue 2277: JSF 2.0 - NoClassDefFoundError: javax.naming.InitialContext - works with 1.2.5 - fails on 1.2.6
6 people starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  Oct 23
Type-Defect
Priority-Medium
Language-Java


Sign in to add a comment
 
Reported by P...@UnnService.com, Oct 16, 2009
When trying to use JSF 2.0, the JSF framework tries to load InitialContext
to see if it is available using this code:

try
Util.getCurrentLoader(this).loadClass("javax.naming.InitialContext");
catch
return false

And the runtime throws the exception that I have posted at the end of this
message. JSF 2.0 works with AppEngine SDK 1.2.5 but fails with 1.2.6,
apparently because of additional checks during that class loading (which is
supposed to fail from within the JSF code).

--------------------------------------------
WARNING: Error starting handlers
Throwable occurred: 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:578)
	at com.sun.faces.config.WebConfiguration.<init>(WebConfiguration.java:114)
	at
com.sun.faces.config.WebConfiguration.getInstance(WebConfiguration.java:174)
	at
com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:157)
	at
org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
	at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
	at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
	at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
	at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
	at org.mortbay.jetty.Server.doStart(Server.java:217)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
	at
com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:181)
	at
com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:116)
	at
com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:217)
	at
com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:162)
	at
com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
	at
com.google.appengine.tools.development.DevAppServerMain.<init>(DevAppServerMain.java:113)
	at
com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:89)
--------------------------------------------
Comment 1 by tobyr+legacy@google.com, Oct 23, 2009
With 1.2.6, the dev_appserver's production security emulation was greatly improved.
For example, whitelisting is now enforced in the dev_appserver. Since InitialContext
isn't on the whitelist, this code fails.

The example code that you posted at top will not run the catch block (I don't know
what exception it's supposed to be catching since you left that out). Just loading a
class doesn't set off the sandbox. If you try to instantiate an instance of the
class, or access a field or method, then you will trip the sandbox in both production
and on the dev_appserver.

I'm closing this issue, because this is the expected behavior.
Status: Invalid
Comment 2 by steph...@voyageonline.co.uk, Oct 24, 2009
Let me disagree, the ClassNotFound exception should be triggered by loadClass() not when a new instance of 
the blacklisted class is instantiated:

http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#loadClass(java.lang.String)
Sign in to add a comment