Expand my Community achievements bar.

SOLVED

Maven Dependencies

Avatar

Level 4

Am building a project and it needs showing me the following errors on the console.

 

     
Imported Packagescom.cognifide.slice.api.injector,version=[4.1,5) -- Cannot be resolved
com.cognifide.slice.commons,version=[4.1,5) -- Cannot be resolved
com.cognifide.slice.cq.module,version=[1.0,2) -- Cannot be resolved
com.cognifide.slice.cq.qualifier,version=[1.0,2) -- Cannot be resolved
com.cognifide.slice.mapper.annotation,version=[4.1,5) -- Cannot be resolved

 

com.google.inject,version=[1.3,2) -- Cannot be resolved
com.ibm.uvm.tools -- Cannot be resolved but is not required
com.sun.jdmk.comm -- Cannot be resolved but is not required and overwritten by Boot Delegation
com.sun.msv.datatype -- Cannot be resolved but is not required and overwritten by Boot Delegation
com.sun.msv.datatype.xsd -- Cannot be resolved but is not required and overwritten by Boot Delegation
com.sun.org.apache.xerces.internal.parsers -- Cannot be resolved but is not required and overwritten by Boot Delegation
com.sun.org.apache.xerces.internal.util -- Cannot be resolved but is not required and overwritten by Boot Delegation
com.sun.org.apache.xerces.internal.xni.parser -- Cannot be resolved but is not required and overwritten by Boot Delegation
groovy.lang -- Cannot be resolved but is not required
javax.jcr,version=[2.0,3) from org.apache.sling.jcr.jcr-wrapper (106)
javax.jcr.nodetype,version=[2.0,3) from org.apache.sling.jcr.jcr-wrapper (106)
javax.jmdns -- Cannot be resolved but is not required
javax.jms -- Cannot be resolved but is not required
javax.naming from org.apache.felix.framework (0)
javax.security.auth.x500 from org.apache.felix.framework (0)
javax.servlet from org.apache.felix.http.servlet-api (29)
javax.xml.bind,version=[2.2,3) -- Cannot be resolved but is not required
junit.framework -- Cannot be resolved but is not required
oracle.xml.parser -- Cannot be resolved but is not required
oracle.xml.parser.v2 -- Cannot be resolved but is not required
org.apache.avalon.framework.logger -- Cannot be resolved but is not required
org.apache.bcel.classfile -- Cannot be resolved but is not required
org.apache.bcel.generic -- Cannot be resolved but is not required
org.apache.bcel.util -- Cannot be resolved but is not required
org.apache.commons.lang,version=[2.6,3) -- Cannot be resolved but is not required
org.apache.commons.lang.builder,version=[2.6,3) -- Cannot be resolved but is not required
org.apache.log -- Cannot be resolved but is not required
org.apache.log4j from log4j.over.slf4j (3)
org.apache.oro.text.regex -- Cannot be resolved but is not required
org.apache.sling.api,version=[2.3,3) from org.apache.sling.api (184)
org.apache.sling.api.request,version=[2.4,3) from org.apache.sling.api (184)
org.apache.sling.api.resource,version=[2.5,3) from org.apache.sling.api (184)
org.apache.sling.api.servlets,version=[2.1,3) from org.apache.sling.api (184)
org.apache.sling.jcr.api,version=[2.2,3) from org.apache.sling.jcr.api (104)
org.apache.xml.resolver -- Cannot be resolved but is not required
org.apache.xml.resolver.readers -- Cannot be resolved but is not required
org.codehaus.groovy.reflection -- Cannot be resolved but is not required
org.codehaus.groovy.runtime -- Cannot be resolved but is not required
org.codehaus.groovy.runtime.callsite -- Cannot be resolved but is not required
org.codehaus.groovy.runtime.typehandling -- Cannot be resolved but is not required
org.codehaus.groovy.runtime.wrappers -- Cannot be resolved but is not required
org.dom4j -- Cannot be resolved but is not required
org.dom4j.io -- Cannot be resolved but is not required
org.gjt.xpp -- Cannot be resolved but is not required
org.jdom -- Cannot be resolved but is not required
org.jdom.input -- Cannot be resolved but is not required
org.osgi.service.component,version=[1.2,2) from org.apache.felix.scr (55)
org.relaxng.datatype -- Cannot be resolved but is not required
org.slf4j,version=[1.6,2) from slf4j.api (14)
org.xmlpull.v1 -- Cannot be resolved but is not required
sun.io -- Cannot be resolved but is not required and overwritten by Boot Delegation

 

 

May I know how can i resolve these issues? I have added the dependencies on the pom.xml still they are not working?

Thanks for reading  the request.

1 Accepted Solution

Avatar

Correct answer by
Level 10

That is the best part of the OSGi service container. Lets say Bundle A wraps the Simple JSON JAR. When you deploy Bundle A to the OSGi Service container -- it exports the Java packages of Simple JSON lib.

Now all other bundles that use the Simple JAR can use it. Therefore 1 OSGi bundle that contains the simple JSON JAR resolves dependencies for many bundles. 

View solution in original post

13 Replies

Avatar

Level 10

The reason why this is occurring is because these Java libs are not part of the OSGi service container.  Just by referencing them in your project's POM does not get them into the OSGi service container. 

You need to create an OSGi bundle that contains the missing JAR files (which contains these Java packages). Then you need to deploy the bundle and place into an active state. 

You can always check if a package exists in AEM by using the AEM dependency finder:

http://localhost:4502/system/console/depfinder

Now as an example of how to wrap JAR files into an OSGi bundle - see this article . We show how we wrapped the simple JSON JAR into an OSGi bundle: 

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

In this article - we use an Eclipse Plug-in project to create the OSGi that wraps the simple JSON jar.  That is what you need to do for all missing packages. 

Avatar

Level 4

Your article link is broken and I'm facing a similar issue.
Can you please update the link.

Avatar

Level 4

Thank you for the reply.

Can I make them as global and get them installed to jcr location.

may I know how i can reference these dependencies on other projects?

Avatar

Correct answer by
Level 10

That is the best part of the OSGi service container. Lets say Bundle A wraps the Simple JSON JAR. When you deploy Bundle A to the OSGi Service container -- it exports the Java packages of Simple JSON lib.

Now all other bundles that use the Simple JAR can use it. Therefore 1 OSGi bundle that contains the simple JSON JAR resolves dependencies for many bundles. 

Avatar

Level 4

thank you so much for your help. it works for me.

Avatar

Former Community Member

What if you already have a .jar file that has OSGI support (for example json simple: https://code.google.com/archive/p/json-simple/downloads). Wouldn't it be easier to just add the .jar file to the /apps/<app_name>/install folder?

Avatar

Level 10

As long as you get the bundle that exposes a Java package (which is the dependency into AEM) - it will resolve the issue. YOu can place the OSGI bundle that contains a dependency in /apps/<app_name>/install. 

Avatar

Level 2

One option is to create separate Maven project and create the jar files there. The result of the execution will be assembled .jar file with all third party libraries in /jcr_root/apps/<come_up_with _name>/install. Mind the META-INF that must be included in the produces jar file.

Rename the resulting .jar file to zip and deploy via package manager.

You can elaborate from there - with Maven caching proxy if you don't want to keep binaries in SCMS, etc.

Regards,

-N

Avatar

Level 9

What's the solution of this problem?.

---Jitendra

Avatar

Level 4

The best solution is import the jar in the osgi console.

I used that refrence in my other project pom.xml.

This resolved my issue.

Avatar

Level 2

Hi Guys, I am facing the below issue, while trying to deploy the osgi bundle for the slice with sightly component. The bundle is getting deployed properly with the below exception on the annotation version. I am using 4.0 version of the slice. 

com.adobe.cq.sightly,version=[2.3,3) from com.adobe.cq.sightly.cq-wcm-sightly-extension (437)

com.cognifide.slice.mapper.annotation,version=[4.2,5) -- Cannot be resolved
com.day.cq.wcm.api,version=[1.8,2) from com.day.cq.wcm.cq-wcm-api (421)
com.fonterra.afp,version=[1.0,2) from com.fonterra.afp.afp-bundle (462)
javax.servlet from org.apache.felix.http.servlet-api (40)
org.apache.sling.api,version=[2.1,3) from org.apache.sling.api (66)
org.apache.sling.api.request,version=[2.1,3) from org.apache.sling.api (66)
org.apache.sling.jcr.api,version=[2.1,3) from org.apache.sling.jcr.api (109)
org.slf4j,version=[1.5,2) from slf4j.api (22)

POM details as per the guideline https://cognifide.atlassian.net/wiki/display/SLICE/Setting+up+-+4.2

Also I am using the below dependency to support AEM6.0+

<dependency>    <groupId>com.cognifide.slice-addon</groupId>    <artifactId>slice-aem60</artifactId>    <version>1.1.0</version></dependency>

Please let me know if I am missing something.

thanks, Sandeep

Avatar

Level 2

Sandeep Rawat wrote...

Hi Guys, I am facing the below issue, while trying to deploy the osgi bundle for the slice with sightly component. The bundle is getting deployed properly with the below exception on the annotation version. I am using 4.0 version of the slice. 

com.adobe.cq.sightly,version=[2.3,3) from com.adobe.cq.sightly.cq-wcm-sightly-extension (437)

com.cognifide.slice.mapper.annotation,version=[4.2,5) -- Cannot be resolved
com.day.cq.wcm.api,version=[1.8,2) from com.day.cq.wcm.cq-wcm-api (421)
com.fonterra.afp,version=[1.0,2) from com.fonterra.afp.afp-bundle (462)
javax.servlet from org.apache.felix.http.servlet-api (40)
org.apache.sling.api,version=[2.1,3) from org.apache.sling.api (66)
org.apache.sling.api.request,version=[2.1,3) from org.apache.sling.api (66)
org.apache.sling.jcr.api,version=[2.1,3) from org.apache.sling.jcr.api (109)
org.slf4j,version=[1.5,2) from slf4j.api (22)

POM details as per the guideline https://cognifide.atlassian.net/wiki/display/SLICE/Setting+up+-+4.2

Also I am using the below dependency to support AEM6.0+

<dependency>    <groupId>com.cognifide.slice-addon</groupId>    <artifactId>slice-aem60</artifactId>    <version>1.1.0</version></dependency>

Please let me know if I am missing something.

thanks, Sandeep

 

 

 

Hi All, I found the weird resolution for this, but this works perfectly, I hope there should be some better options to resolve this kind of issues. Download the slice project from the git repository, run the mvn clean install on the project, this will create a slice-assembly-4.3.0-SNAPSHOT-cq.zip file in the target folder of the assembly. Just install this package through package manager. And just see the osgi bundle in the system/console and you will see all the jar resolutions happening. 

Please suggest if we have better way to handle this kind of issues...cheers, Sandeep

Avatar

Level 9

You are using the wrong artifact.

Change it to below:

<dependency>
    <groupId>com.cognifide.slice</groupId>
    <artifactId>slice-mapper-api</artifactId>
    <version>3.1.0</version>
</dependency>