Sunday, August 11, 2013

Issue encounter and simple note on Google AppEngine exploration

Issue 1

During the deployment of the sample app "Guestbook" to AppEngine through Eclipse, error message "Unable to update app: Cannot get the System Java Compiler. Please use a JDK, not a JRE." is prompted. Please refer to the screenshot as shown below:


Steps to resolve
1. Open the eclipse.ini, normally located at "ECLIPSE home path".
2. Add configuration as shown below in the first line of eclipse.ini.
-vm
[JAVA_HOME_PATH]/bin/javaw.exe
3. Restart Eclipse and redeploy the app to AppEngine, you will be able to get this through.

Issue 2

Try to use Jersey (version 1.7) to create JAX-RS service on Google App Engine, please refer to http://tugdualgrall.blogspot.sg/2010/02/create-and-deploy-jax-rs-rest-service.html.
Encounter the error in AppEngine log as described below when use browser to call the service.

Uncaught exception from servlet
java.lang.IncompatibleClassChangeError: Implementing class
 at com.google.appengine.runtime.Request.process-638cb79974cf6c0a(Request.java)
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:794)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
 at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:601)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:359)
 at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
 at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
 at com.sun.jersey.api.core.PackagesResourceConfig.(PackagesResourceConfig.java:78)
 at com.sun.jersey.api.core.PackagesResourceConfig.(PackagesResourceConfig.java:89)
 at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:696)
 at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:674)
 at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
 at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
 at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
 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:435)
 at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:442)
 at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:186)
 at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:306)
 at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:298)
 at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:439)
 at java.lang.Thread.run(Thread.java:722)

Steps to resolve
1. Right click project in Eclipse and select "Properties".
2. Change "Datanuclues JDO/JPA version to "v1". Please refer to screenshot as described below.


3. Redeploy the app to AppEngine. You should be able to call the service.

Reason: The used of asm-4.0.jar by AppEngine crash with the Jersey 1.7.

1 comment:

Raman said...

Thanks a lot for this post. Actually I faced issues as you did. before hitting your blog I read 4-5 stackoverflow posts telling to use jarjar tool and i did use tht but in vain your simple solution saved my day.,.,seriously thanks for publishing this.