Problem with Google AppEngine and Jersey with Java


I recently came across a significant problem with Google AppEngine 1.7.2 and Jersey. Whenever I tried to implement my Webservice, I got a 500 error. There was nothing really wrong with the code. So i took a look at the Logs in the Google AppEngine Dashboard and found the following exception:

 

//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js //

 

Uncaught exception from servlet
java.lang.IncompatibleClassChangeError: Implementing class
	at com.google.appengine.runtime.Request.process-642025ace6e60966(Request.java)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
	at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:68)
	at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:110)
	at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:76)
	at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:87)
	at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:641)
	at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:619)
	at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:199)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:307)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:470)
	at javax.servlet.GenericServlet.init(GenericServlet.java:212)
	at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
	at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
	at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
	at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
	at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:452)
	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:458)
	at com.google.tracing.TraceContext.runInContext(TraceContext.java:698)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:336)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:328)
	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:456)
	at java.lang.Thread.run(Thread.java:679)
This exception is caused by compatibility issues between asm-4.0.jar and asm-3.1.jar. With the new Version of AppEngine, asm-4.0.jar is used and it is not compatible with Jersey, which relies on asm-3.1.jar. To make Jersey still work on GAE 1.7, you have to remove the dependency on asm-4.0.jar.

[widgets_on_pages id=”sb”]

To remove the dependency, simply right-click on the referenced library "asm-4.0.jar", select "Build Path" and click on "Remove from Build Path". You also have to remove the file physically.
However, now that you changed that, you will still run into other problems. Datanucleus 2.0 relies on asm-4.0.jar and now that we removed the dependency, we can't use it any more. Therefore, it is necessary to switch to Version 1.0. You can do this simply by right-clicking on the project - select "Google" - "App Engine Settings". In this dialog, simply switch to Version 1.0 and you are ready to go (again)
Set Datanucelus Version to 1.0 in Eclipse for AppEngine
Set Datanucelus Version to 1.0 in Eclipse for AppEngine
Advertisements

Published by

Mario Meir-Huber

I work as Big Data Architect for Microsoft. With this role, I support my customers in applying Big Data technologies - mainly Hadoop/Spark - for their use-cases. I also teach this topic at various universities and frequently speak at various Conferences. In 2010 I wrote a book about Cloud Computing, which is often used at German & Austrian Universities. In my home country (Austria) I am part of several organisations on Big Data.

One thought on “Problem with Google AppEngine and Jersey with Java”

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s