Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.JavaType not found

I am using jackson libs in my application and when I build the code (using ant), the build is successful. And I have tried mock testing by using those methods in unit testing and its working fine. But when starting karaf, it gives me this error:

Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.JavaType not found by com.project.test.application [224]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

And these are the jars I am downloading in my ivy.xml:

<dependency org="com.fasterxml.jackson.core" name="jackson-core" rev="2.4.4" transitive="false" />
<dependency org="com.fasterxml.jackson.core" name="jackson-annotations" rev="2.4.4" transitive="false" />
<dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.4.4" transitive="false" />

I have tried changing the versions, but still the same error. Do I have to load these jars after downloading? I have kept the default place as ivy-lib and that process is working for all the other jars I am downloading. What is going wrong? Does this require a specific version or any other dependency? Or is there other way to load these jar files?

My classpath in build.xml

<path id="compile.classpath">
    <fileset dir="${ivy.lib}">
      <include name="*.jar"/>
    </fileset>
</path>
like image 904
Siddharth Avatar asked Oct 29 '16 09:10

Siddharth


1 Answers

I was getting this error because someone else in some other class was using org.codehaus.jackson package and I am using com.fasterxml.jackson package. And because of this conflict of jars, it was throwing this ClassNotFoundException. Once I removed and replaced those fasterxml jars with codehaus jars, it started working fine.

like image 192
Siddharth Avatar answered Sep 23 '22 11:09

Siddharth