Posted by: Josh | October 17, 2009

Mojarra JSF 2.0 RC2 and Google App Engine SDK 1.2.6

So a recent update to the Google App Engine SDK broke my JSF 2.0 web application. I received this message on local server start-up:

WARNING: Error starting handlersGoogle_App_Engine_logo_wtxt
Throwable occurred: java.lang.NoClassDefFoundError:
javax.naming.InitialContext is a restricted class. Please see the Google
App Engine developer’s guide for more details.

Apparently this was due to how JSF checks if it can use InitialContext first  (bug report)- by invoking it. Unfortunately, this sends GAE into a panic, since javax.naming.InitialContext is not one of the whitelisted JRE classes.

**Edit 3: for your convenience, I have pre-packaged this solution into its own .jar file. See bottom of post for further details.

Note: If you haven’t yet set up your JSF-enabled GAE project, follow this guide.

The solution: override the JSF implementation of WebConfiguration, at least until GAE or Mojarra put out a fix. At the very least, this will let you once again use JSF on 1.2.6 locally – I’m still hitting an error 500 when deployed on the app server, but it might be due to some other libs in my web app*. Please post a comment if you find a better solution!**

Here are the steps I took:

  1. Add jsf-api.jar and jsf-impl.jar to your build path.
  2. Create the package structure com.sun.faces.config
  3. Create a WebConfiguration class in com.sun.faces.config and put in the following code [.java link].

Make sure that, if you’ve just updated the GAE plugin in Eclipse, that your project has been updated to use GAE 1.2.6 too.

*Edit: the error 500 I stated earlier was in fact due to another library causing a crash – probably another 1.2.6 incompatibility? So if you implement this patch, other libraries aside, you should be able to run your app locally and on app engine.

Edit 2: the error 500 was due to an old Jersey core/client implementation, and upgrading to 1.0.3 fixed it. Also, if you’re in Eclipse and need to upgrade your 1.2.5 web project to 1.2.6 but get an error about “dev_appserver” or “KickStart”, just add the following argument to your Run Configuration’s Arguments/vm tab:


Where C:\eclipse is where Eclipse has been installed.

**Edit 3: for your convenience, I have pre-packaged this solution into its own .jar file, which can be used interchangeably with the official jsf-impl.jar. Neither jsf-impl-gae.jar or jsf-api.jar, or the aforementioned solution have to be on the build path with this solution. Just place this in /war/WEB-INF/lib and delete the original jsf-impl.jar.

Download jsf-impl-gae.jar | Full Readme | Eclipse project on SVN

And if you’re interested in the fix on the Sun Jersey Core library, see my post here.




  1. Thanks a lot for this Josh. It’s saved me a lot of work.

  2. Thank you Josh!

  3. […] ran into the problem detailed here  ( JNDI problem in jsf 2.0 and google app engine ) right off the bat.  I tried to use his packaged jar, but app-engine kept giving me an exception […]

  4. this solution applies to sdk 1.3.0?

  5. Thank you, Josh. You Class seems to be working on 1.3.0, too.

    Would you happen to know if this will be resolved directly by either the mojarra project or the gae project in a future release.

    I saw your solution mentioned in one of the bug comments and thought that you might be “in the know.”

  6. @Scott, Mirco: you’re welcome!
    @Gleidson: looks like from Dennis’ tests, this solution is still compatible
    @Dennis: I’m not affiliated with either project, so I can’t provide you any estimates on a proper fix – sorry!

  7. Another thanks here Josh. Used it to get GAE working with PrimeFaces, Spring and Maven.

  8. I got the problem stated here in the first instance.
    I wonder why this site doesn’t mention of this problem.
    Your fix worked like a charm! Thanks, you saved my day.

  9. […] but couldn’t figure out the source of this exception. Then I’ve Googled this article. I’ve followed instructions on this blog (thanks Josh) com.sun.faces.config.WebConfiguration […]

  10. Thanks a lot for this!!

  11. Hi,

    Thanks a lot for the jar – worked great for JSF2.

    I was trying to use seam-2.2.1.CR1 with JSF2. But the deployment fails with the following stack trace as soon as I add the seam jars.

    Any help is greatly appreciated.



    com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! com.sun.facelets.compiler.Compiler
    at com.sun.faces.config.ConfigManager.initialize(
    at com.sun.faces.config.ConfigureListener.contextInitialized(
    at org.mortbay.jetty.handler.ContextHandler.startContext(
    at org.mortbay.jetty.servlet.Context.startContext(
    at org.mortbay.jetty.webapp.WebAppContext.startContext(
    at org.mortbay.jetty.handler.ContextHandler.doStart(
    at org.mortbay.jetty.webapp.WebAppContext.doStart(
    at org.mortbay.component.AbstractLifeCycle.start(
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(
    at org.mortbay.component.AbstractLifeCycle.start(
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(
    at org.mortbay.jetty.Server.doStart(
    at org.mortbay.component.AbstractLifeCycle.start(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at com.intellij.rt.execution.application.AppMain.main(
    Caused by: java.lang.ClassNotFoundException: com.sun.facelets.compiler.Compiler
    at Method)
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.ClassLoader.loadClassInternal(
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(
    at java.lang.Class.getConstructor0(
    at java.lang.Class.getDeclaredConstructor(
    at Method)
    at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(
    at com.sun.faces.config.processor.LifecycleConfigProcessor.addPhaseListeners(
    at com.sun.faces.config.processor.LifecycleConfigProcessor.process(
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(
    at com.sun.faces.config.ConfigManager.initialize(

  12. Thanks man that was nice.
    Just FYI.. I know people are genious still..

    when you go on

    for downloading jar just click on “view raw file”

  13. Hi Josh,

    The issue that you pointed to has been closed as invalid – they say it is expected behavior?

  14. Don’t use this jar anymore. its outdated…

    go and get yourself the latest mojjara and binary and get the and rop it into com.sun.faces.config and comment the entire body of the method private void processJndiEntries(String contextName)

    this jar was great and very helpfull in the past… used it for a while… but now its outdated….

  15. Here you can find the complete tutorial on how to use the original mojarra jars with GAE :

  16. […] a look at this site and download this file […]

  17. […] Article discussing the solution to the ‘javax.naming.InitialContext is a restricted class’ problem. (link) […]

  18. […] for the java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. error.  Here it is   If you enjoyed this article, please consider sharing […]

  19. […] Mojarra JSF 2.0 RC2 and Google App Engine SDK 1.2.6 « Josh Carrier’s Blag […]

  20. replacing jsf-impl.jar with jsf-impl-gae.jar worked very well

    thank you very much

  21. […] Mojarra JSF 2.0 RC2 and Google App Engine SDK 1.2.6 This article is under – GAE Tutorials , Tags : error gae jsf2 mkyong Founder and Chief Editor of, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. […]

  22. […] JSF 2 impl jar fix – Josh has kindly provided a fix for JSF impl jar which resolves the startup problem […]

  23. Your method of telling all in this article is genuinely pleasant, all
    can without difficulty know it, Thanks a lot.

  24. […] Mojarra JSF 2.0 RC2 and Google App Engine SDK 1.2.6 « Josh Carrier’s Blag […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: