loader constraint violation

atulj76172708 25-10-2018

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..

Accepted Solutions (1)

Accepted Solutions (1)

PuzanovsP
MVP
25-10-2018

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

Answers (4)

Answers (4)

Jörg_Hoh
Employee
26-10-2018

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

atulj76172708 26-10-2018

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.

atulj76172708 25-10-2018

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.