Expand my Community achievements bar.

SOLVED

loader constraint violation

Avatar

Level 3

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

5 Replies

Avatar

Level 3

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.

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 3

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.

Avatar

Employee Advisor

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

Avatar

Level 3

Restart the causing server from felix console and try again.

Regards,

Mayank Saxena

Cognizant