IncompatibleClassChangeError

IncompatibleClassChangeError

本文介绍了java.lang.IncompatibleClassChangeError:实现类部署到应用引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 JRE 1.6 上使用 Jersey 1.13 编写了几个 REST 服务.一切都在本地运行良好,但在我部署到 GAE 后出现此错误:

I wrote a couple of REST services using Jersey 1.13 on JRE 1.6. Everything runs fine locally, but after I deploy to GAE I get this error:

****Uncaught exception from servlet
java.lang.IncompatibleClassChangeError: Implementing class
    at com.google.appengine.runtime.Request.process-139e1bda14d5aebc(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:79)
    at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
    at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
    at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
    at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:700)
    at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
    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: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)****

任何帮助将不胜感激.

推荐答案

这个异常是asm-4.0.jar和asm-3.1.jar的兼容性问题引起的.使用新版本的 AppEngine,使用 asm-4.0.jar,它与依赖 asm-3.1.jar 的 Jersey 不兼容.要使 Jersey 仍然可以在 GAE 1.7 上运行,您必须删除对 asm-4.0.jar 的依赖.

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.

查看这篇文章:http://cloudvane.com/2012/09/23/problem-with-google-appengine-and-jersey-with-java/

经过测试和验证,如下所示:

It s tested and verified, like that:

  1. 将 asm-3.3.1.jar 添加到你的 war->lib
  2. 将它添加到你的重新构建路径
  3. 物理删除 asm-4.0.jar
  4. 项目 -> 属性 -> Google -> AppEngine:将 Datanuclueus 切换到 v1

就是这样!

这篇关于java.lang.IncompatibleClassChangeError:实现类部署到应用引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 07:32