Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jackson + Tomcat - java.lang.VerifyError: Cannot inherit from final class

I have a Java webservice running in Tomcat 6 which accepts JSON input. I am trying to use Jackson ObjectMapper to parse the input json. But when initializing the ObjectMapper object I am getting this error

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();

When calling com.test.project.offline.ws.WsApiResource.updateData() method locally in a unit test it works without any error.

Kindly help me in fixing this. I am using Jackson 1.8.4 and tomcat 6.

UPDATE: Fixed the issue. Problem was a different version of jackson in the dependency tree. Excluding it fixed the problem.

like image 835
Jithin Avatar asked Oct 14 '11 10:10

Jithin


2 Answers

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.

like image 173
Tristan Ratchford Avatar answered Sep 24 '22 08:09

Tristan Ratchford


I had the same issue with Apache Solr, and it was resolved by deleting my ~/.m2 cache.

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.

Maven really should have some sort of conflicting versions of dependency resolution scheme...

like image 36
Neil Avatar answered Sep 20 '22 08:09

Neil