Jackson + Tomcat - java.lang.VerifyError:无法从最终类继承
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7766614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hymanson + Tomcat - java.lang.VerifyError: Cannot inherit from final class
提问by Jithin
I have a Java webservice running in Tomcat 6 which accepts JSON input. I am trying to use Hymanson ObjectMapper to parse the input json. But when initializing the ObjectMapper object I am getting this error
我有一个在 Tomcat 6 中运行的 Java Web 服务,它接受 JSON 输入。我正在尝试使用 Hymanson ObjectMapper 来解析输入的 json。但是在初始化 ObjectMapper 对象时,我收到此错误
16:08:13,616 ERROR [[jersey]] Servlet.service() for servlet jersey threw exception
java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2733)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at com.test.project.offline.ws.WsApiResource.updateData(WsApiResource.java:169)
.......
At line 169 I have this ObjectMapper mapper = new ObjectMapper();
在第 169 行,我有这个 ObjectMapper mapper = new ObjectMapper();
When calling com.test.project.offline.ws.WsApiResource.updateData() method locally in a unit test it works without any error.
在单元测试中本地调用 com.test.project.offline.ws.WsApiResource.updateData() 方法时,它可以正常工作而不会出现任何错误。
Kindly help me in fixing this. I am using Hymanson 1.8.4 and tomcat 6.
请帮我解决这个问题。我正在使用 Hymanson 1.8.4 和 tomcat 6。
UPDATE: Fixed the issue. Problem was a different version of Hymanson in the dependency tree. Excluding it fixed the problem.
更新:修复了这个问题。问题是依赖关系树中的 Hymanson 版本不同。排除它解决了问题。
回答by Tristan Ratchford
I also had the same issue with Apache Lucene. I had lucene-core-3.6.0.jar and lucene-core-3.5.0.jar in my /WEB-INF/lib folder. Removing one or the other also fixed my problem. It must be a versioning issue.
我在 Apache Lucene 上也遇到了同样的问题。我的 /WEB-INF/lib 文件夹中有 lucene-core-3.6.0.jar 和 lucene-core-3.5.0.jar 。删除一个或另一个也解决了我的问题。应该是版本问题。
回答by Neil
I had the same issue with Apache Solr, and it was resolved by deleting my ~/.m2
cache.
我在 Apache Solr 上遇到了同样的问题,通过删除我的~/.m2
缓存解决了这个问题。
This issue was also caused by specifying the wrong version of a dependency in my pom.xml
file, where another package was automatically downloading another version.
此问题也是由于在我的pom.xml
文件中指定了错误版本的依赖项而导致的,其中另一个包会自动下载另一个版本。
Maven really should have some sort of conflicting versions of dependency resolution scheme...
Maven 确实应该有某种相互冲突的依赖项解析方案版本......
回答by Daniel Schwager
The same for me - my ejb3 application uses Hymanson-all-1.9.4 - and my glassfish container (v2.1) contains a lib/Hymanson-asl-0.9.4.jar:
对我来说也是一样 - 我的 ejb3 应用程序使用 Hymanson-all-1.9.4 - 我的 glassfish 容器(v2.1)包含一个 lib/Hymanson-asl-0.9.4.jar:
java.lang.VerifyError: Cannot inherit from final class
Now, I have replaced Hymanson-all with gson.
现在,我用 gson 替换了 Hymanson-all。
Thanks,
谢谢,
Danny
丹尼
回答by Decoded
Neil has a great answer to this question. However, aside from your M2 cache, check if you're a complete DUMMY like I WAS and ensure your POM doesn't include two packages where the same Final class is declared. Google API's are notorious for cross including classes in their API Jars. Ensure you delete EVERYTHING you don't need!
尼尔对这个问题有很好的回答。但是,除了您的 M2 缓存之外,请检查您是否像 I WAS 一样是一个完整的 DUMMY,并确保您的 POM 不包含两个声明相同 Final 类的包。Google API 因其 API 罐中的交叉包含类而臭名昭著。确保删除所有不需要的东西!