Monday, May 19, 2014

Google appengine devserver NoClassDefFoundError "is a restricted class"

While trying to migrate an Eclipse Appengine project to a Maven one, I ran into a NoClassDefFoundError exception when starting the DevAppServerMain (com.google.appengine.tools.development) via the appengine-maven-plugin using appengine version (1.9.4) . 

The same project would run when started within Eclipse when using the Eclipse Appengine plugin but not when started using the Maven one; neither within Eclipse nor on the command line. Every time, I got the same error:

HTTP ERROR 500
Problem accessing /_ah/admin. Reason:    javax.servlet.FilterChain is a restricted class. Please see the Google  App Engine developer's guide for more details. 

I worked on this problem for a long time. Delved into the DevAppServerMain code, the appengine-maven-plugin code, java agents and lots of other things but could not solve the issue. Eventally, I solved it by complete coincidence. 

In my efforts to find the cause, I had created a Maven project using the the following archetype: com.google.appengine.demos:guestbook-archetype. I imported it into Eclipse as a Maven project using the pom and then ran the appengine:devserver goal, which started; however, when I ran it from the command line it didn't. When I compared the two, I saw that they were using different Java installations: The one that would not work properly was running with with:

set JAVA_HOME=c:\Program Files (x86)\Java\jdk1.7.0_40

and the one that worked with:

set JAVA_HOME=c:\Program Files\Java\jdk1.7.0_25

In summary: It had to do with the Jdk. Why still needs to be determined.

1 comment:

  1. Thank you so much! I was using 1.7.0_55 of the JDK, and having the same problem with FilterChain. I changed to 1.7.0_21 (in the Eclipse Debug Configurations, on the JRE tab) and it worked! I'll post this to StackOverflow and add a link to your blog.

    ReplyDelete