loader constraint violation | Community
Skip to main content
Level 3
Oct 25, 2018 6:42 PM UTC
Solved

loader constraint violation

Hello Team,

I am facing a unique issue with JSON Exporter on my local machine.

Whenever I try running a JSON Exporter service I receive below error in the log file.

org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException

java.lang.LinkageError: loader constraint violation: when resolving method "com.fasterxml.jackson.core.JsonFactory.setCharacterEscapes(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the current class, org/apache/sling/models/jacksonexporter/impl/JacksonExporter, and the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for the method's defining class, com/fasterxml/jackson/core/JsonFactory, have different Class objects for the type com/fasterxml/jackson/core/io/CharacterEscapes used in the signature

Below is the POM definition for Jackson Jar's.

              <dependency>

                <groupId>com.fasterxml.jackson.core</groupId>

                <artifactId>jackson-core</artifactId>

                <version>2.3.2</version>

                <scope>provided</scope>

            </dependency>

            <dependency>

                <groupId>com.fasterxml.jackson.core</groupId>

                <artifactId>jackson-databind</artifactId>

                <version>2.3.2</version>

                <scope>provided</scope>

            </dependency>

            <dependency>

                <groupId>com.fasterxml.jackson.core</groupId>

                <artifactId>jackson-annotations</artifactId>

                <version>2.3.2</version>

                <scope>provided</scope>

            </dependency>

Strange enough the same code works fine on another server, but fails on my machine.. have tried all possible options.

Any ideas/suggestions directions would really help.

Thank you..

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Peter_Puzanovs
Peter_PuzanovsAccepted solution
New Participant
Oct 26, 2018 6:58 AM UTC

Dear Atul,

You shouldn't need to define versions or these 3 dependencies in your code base.

They should be coming form the Uber-Jar. The only caveat is that Uber-Jar version needs to be the same version as your AEM instance.

Regards,

Peter

5 replies

Level 2
Jan 29, 2020 11:47 AM UTC

Restart the causing server from felix console and try again.

Regards,

Mayank Saxena

Cognizant

Translate
joerghoh
Employee
Oct 26, 2018 8:08 PM UTC

Hi,

That's a classloader issue. Which bundle is exporting the package "com.fasterxml.jackson.core"? Maybe it's exported by the System Bundle (and then it's taken from the JRE itself) and also exported by a bundle which embeds a copy of the jackson library?

Jörg

Translate
AlthamAuthor
Level 3
Oct 26, 2018 2:38 PM UTC

Sure, Thank you for this suggestion PuzanovsP  I'll try removing it.

I am working on AEM 6.2 SP1 CFP16 system. So the uber jar 6.2 is in use. I'll de-compile 6.2 uber-jar and see if I figure out the root cause.

Translate
Peter_Puzanovs
Peter_PuzanovsAccepted solution
New Participant
Oct 26, 2018 6:58 AM UTC

Dear Atul,

You shouldn't need to define versions or these 3 dependencies in your code base.

They should be coming form the Uber-Jar. The only caveat is that Uber-Jar version needs to be the same version as your AEM instance.

Regards,

Peter

Translate
AlthamAuthor
Level 3
Oct 25, 2018 6:57 PM UTC

Strange enough, I bumped up the the versions of jackson-core, jackson-annotations, & jackson-databind to near high version (2.6.0)

And the issue seems to be resolved.

I am still not clear the exact root cause for the loader constraint voilation with version (2.3.2) which failed only on my local machine.

Translate