Caused by: java.lang.LinkageError: | Community
Skip to main content
New Participant
October 16, 2015
Solved

Caused by: java.lang.LinkageError:

  • October 16, 2015
  • 4 replies
  • 3584 views
can anyone tell me how I solve the problem?loader constraint violation: when resolving interface method "NavigationService.getNav()Lorg/json/JSONObject;" the class loader (instance of org/apache/sling/commons/fsclassloader/impl/FSDynamicClassLoader) of the current class, org/apache/jsp/apps/global/components/skizz_005f1_005f4_005f0/molecules/navigations/nav_jsp, and the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for the method's defining class, NavigationService, have different Class objects for the type org/json/JSONObject used in the signature
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Looks like you did not bundle the JSON Java JAR into an OSGi bundle.

When referencing a Java lib (a JAR) in your AEM service - you need to:

1 - reference it into your POM (which you did)

2 - place into an OSGi bundle and place in active state

See this community article that shows how to bundle JSON Java JAR into a bundle fragment and deploy:

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

4 replies

suniln68723412
New Participant
September 26, 2017

I to facing the similar issue , The error i am facing is .

Caused by: java.lang.LinkageError:

loader constraint violation: when resolving interface method

"com.day.cq.wcm.api.Page.listChildren(Lcom/day/cq/commons/Filter;)Ljava/util/Iterator;" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the current class,

com/thermo/wcm/tags/Functions, and the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for the method's defining class,

com/day/cq/wcm/api/Page, have different Class objects for the type com/day/cq/commons/Filter used in the signature

smacdonald2008
New Participant
October 16, 2015

Please provide more details - looks like you are trying to build an OSGi bundle via Maven - what APIs are you working with and have included in your POM file's dependencies section?

wmakendAuthor
New Participant
October 16, 2015

Yes i have make a Java Class(Service) That return a json object. 

-----

 

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20140107</version>
        </dependency>

import org.json.JSONObject;

 

  public JSONObject getNav() {
       JSONObject objNav = new JSONObject().put("nav", nav);
       return objNav;
    }

------

I have Deploy it in OSGI Console.

Nkow the Probleme ist i want to use it in my JSP File

<%@ page import="com.day.cq.wcm.api.WCMMode,
org.json.JSONObject" %>

<% yy.etat.xx.NavigationService NavigationService = sling.getService(yy.etat.xx.NavigationService.class); %>

/// THE ERROR CAME FORM HIER

NavigationService.getNav();

 

iT RETURN A JSON oBJECT

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

Looks like you did not bundle the JSON Java JAR into an OSGi bundle.

When referencing a Java lib (a JAR) in your AEM service - you need to:

1 - reference it into your POM (which you did)

2 - place into an OSGi bundle and place in active state

See this community article that shows how to bundle JSON Java JAR into a bundle fragment and deploy:

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html