Expand my Community achievements bar.

SOLVED

Caused by: java.lang.LinkageError:

Avatar

Level 2
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
1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

4 Replies

Avatar

Level 10

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?

Avatar

Level 2

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

Avatar

Correct answer by
Level 10

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

Avatar

Level 1

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