Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to import dom4j dependency for OSGI bundle

Avatar

Former Community Member

hi there,

because of using dom4j to parse and create XML format document, as a result i add dependency to pom.xml

<dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.1</version> </dependency>

 

After run command "mvn clean install" and deploy this jar to OSGI bundle pool. Eventually appear error: org.dom4j -- Cannot be resolved, illustration following:

[img]dom4j.png[/img]

Anyone could help see it? Thanks a lot.

 

Best regards,

Brian

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

hi,

i find a solution to resolve this problem as below:

<Import-Package> com.sun.msv.*;resolution:=optional, nu.xom;resolution:=optional, org.gjt.xpp;resolution:=optional, org.jdom.*;resolution:=optional, org.relaxng.datatype;resolution:=optional, org.xmlpull.v1;resolution:=optional, * </Import-Package>

 

After deployment and it helps. But i not sure if it is right?

Anyway thanks a lot for your help.

View solution in original post

8 Replies

Avatar

Level 10

Brian,

 dom4j is a 3rd party jar and it would not be available in the CQ. Hence it would be throwing that error.

Include the <Embed-Dependency> in your pom.xml like below and you should resolve this

 

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Embed-Dependency>dom4j</Embed-Dependency> <Import-Package></Import-Package> <Export-Package></Export-Package> <Bundle-SymbolicName></Bundle-SymbolicName> </instructions> </configuration> </plugin>

Avatar

Former Community Member

hi bsloki,

thanks for your reply. And i add dependency to pom.xml as below:

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Bundle-Category>cq5</Bundle-Category> <Embed-Dependency> dom4j, jaxen </Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> <Import-Package> * </Import-Package> </instructions> </configuration> </plugin>

But after deploy it apear error again, please see following:

com.day.cq.commons.jcr,version=[5.7,6) from com.day.cq.cq-commons (263)
com.day.cq.wcm.api,version=[1.1,2) from com.day.cq.wcm.cq-wcm-api (368)
com.sun.msv.datatype -- Cannot be resolved and overwritten by Boot Delegation
com.sun.msv.datatype.xsd -- Cannot be resolved and overwritten by Boot Delegation

javax.jcr,version=[2.0,3) from org.apache.sling.jcr.jcr-wrapper (106)
javax.servlet.http from org.apache.felix.http.servlet-api (29)
javax.swing.table from org.apache.felix.framework (0)
javax.swing.tree from org.apache.felix.framework (0)
javax.xml.bind from org.apache.felix.framework (0)
javax.xml.namespace from org.apache.felix.framework (0)
javax.xml.parsers from org.apache.felix.framework (0)
javax.xml.stream from org.apache.felix.framework (0)
javax.xml.stream.events from org.apache.felix.framework (0)
javax.xml.stream.util from org.apache.felix.framework (0)
javax.xml.transform from org.apache.felix.framework (0)
javax.xml.transform.sax from org.apache.felix.framework (0)
javax.xml.transform.stream from org.apache.felix.framework (0)
nu.xom -- Cannot be resolved
org.apache.commons.fileupload.servlet from org.apache.commons.fileupload (23)
org.apache.jackrabbit.commons,version=[2.4,3) from org.apache.jackrabbit.jackrabbit-jcr-commons (99)
org.apache.sling.api,version=[2.2,3) from org.apache.sling.api (184)
org.apache.sling.api.request,version=[2.2,3) from org.apache.sling.api (184)
org.apache.sling.api.resource,version=[2.1,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.0,3) from org.apache.sling.jcr.api (104)
org.gjt.xpp -- Cannot be resolved
org.jdom -- Cannot be resolved
org.jdom.input -- Cannot be resolved

org.osgi.framework,version=[1.5,2) from org.apache.felix.framework (0)
org.osgi.service.component,version=[1.1,2) from org.apache.felix.scr (55)
org.relaxng.datatype -- Cannot be resolved
org.slf4j,version=[1.5,2) from slf4j.api (14)
org.xml.sax from org.apache.felix.framework (0)
org.xml.sax.ext from org.apache.felix.framework (0)
org.xml.sax.helpers from org.apache.felix.framework (0)
org.xmlpull.v1 -- Cannot be resolved

Avatar

Former Community Member

And also it seems like a dependency hell even though i add the rest xom, pull-parser, jdom,xpp3, xsdlib and so on.

Avatar

Level 10

Hey Can you put the manifest file here.. it would be easy to debug

Also, try with 

  1. <Embed-Dependency>
  2. dom4j, jaxen ;scope=compile|runtime;inline=false
  3. </Embed-Dependency>
 

Avatar

Former Community Member

hi bsloki,

Again modify that pom.xml as per your comment, but error either as following:

Imported Packages com.day.cq.commons.jcr,version=[5.7,6) from com.day.cq.cq-commons (263)
com.day.cq.wcm.api,version=[1.1,2) from com.day.cq.wcm.cq-wcm-api (368)
com.sun.msv.datatype -- Cannot be resolved and overwritten by Boot Delegation
com.sun.msv.datatype.xsd -- Cannot be resolved and overwritten by Boot Delegation

javax.jcr,version=[2.0,3) from org.apache.sling.jcr.jcr-wrapper (106)
javax.servlet.http from org.apache.felix.http.servlet-api (29)
javax.swing.table from org.apache.felix.framework (0)
javax.swing.tree from org.apache.felix.framework (0)
javax.xml.bind from org.apache.felix.framework (0)
javax.xml.namespace from org.apache.felix.framework (0)
javax.xml.parsers from org.apache.felix.framework (0)
javax.xml.stream from org.apache.felix.framework (0)
javax.xml.stream.events from org.apache.felix.framework (0)
javax.xml.stream.util from org.apache.felix.framework (0)
javax.xml.transform from org.apache.felix.framework (0)
javax.xml.transform.sax from org.apache.felix.framework (0)
javax.xml.transform.stream from org.apache.felix.framework (0)
nu.xom -- Cannot be resolved
org.apache.commons.fileupload.servlet from org.apache.commons.fileupload (23)
org.apache.jackrabbit.commons,version=[2.4,3) from org.apache.jackrabbit.jackrabbit-jcr-commons (99)
org.apache.sling.api,version=[2.2,3) from org.apache.sling.api (184)
org.apache.sling.api.request,version=[2.2,3) from org.apache.sling.api (184)
org.apache.sling.api.resource,version=[2.1,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.0,3) from org.apache.sling.jcr.api (104)
org.gjt.xpp -- Cannot be resolved
org.jdom -- Cannot be resolved
org.jdom.input -- Cannot be resolved

org.osgi.framework,version=[1.5,2) from org.apache.felix.framework (0)
org.osgi.service.component,version=[1.1,2) from org.apache.felix.scr (55)
org.relaxng.datatype -- Cannot be resolved
org.slf4j,version=[1.5,2) from slf4j.api (14)
org.xml.sax from org.apache.felix.framework (0)
org.xml.sax.ext from org.apache.felix.framework (0)
org.xml.sax.helpers from org.apache.felix.framework (0)
org.xmlpull.v1 -- Cannot be resolved

 

And i put the manifest here for your reference:

Manifest-Version: 1.0 Bnd-LastModified: 1418956844663 Build-Jdk: 1.6.0_45 Built-By: brian.lei Bundle-Category: cq5 Bundle-ClassPath: .,dom4j-1.6.1.jar,jaxen-1.1.1.jar Bundle-Description: Maven Multimodule project for Claim Training Package . Bundle-ManifestVersion: 2 Bundle-Name: Claim Training Package Bundle Bundle-SymbolicName: com.adobe.cq.sling.claim-bundle Bundle-Version: 1.0.0.SNAPSHOT Created-By: Apache Maven Bundle Plugin Embed-Dependency: dom4j, jaxen ;scope=compile|runtime;inline=false Embed-Transitive: true Embedded-Artifacts: dom4j-1.6.1.jar;g="dom4j";a="dom4j";v="1.6.1",jaxen- 1.1.1.jar;g="jaxen";a="jaxen";v="1.1.1" Export-Package: com.adobe.cq.sling;uses:="javax.jcr,com.day.cq.wcm.api,o rg.apache.jackrabbit.commons,com.day.cq.commons.jcr,org.slf4j,org.apach e.sling.api.resource,org.apache.sling.api.servlets,org.apache.sling.jcr .api,org.apache.sling.api,org.osgi.framework,org.apache.sling.api.reque st,org.apache.commons.fileupload.servlet,javax.servlet.http,org.osgi.se rvice.component";version="1.0.0.SNAPSHOT" Import-Package: com.day.cq.commons.jcr;version="[5.7,6)",com.day.cq.wcm. api;version="[1.1,2)",com.sun.msv.datatype,com.sun.msv.datatype.xsd,jav ax.jcr;version="[2.0,3)",javax.servlet.http,javax.swing.table,javax.swi ng.tree,javax.xml.bind,javax.xml.namespace,javax.xml.parsers,javax.xml. stream,javax.xml.stream.events,javax.xml.stream.util,javax.xml.transfor m,javax.xml.transform.sax,javax.xml.transform.stream,nu.xom,org.apache. commons.fileupload.servlet,org.apache.jackrabbit.commons;version="[2.4, 3)",org.apache.sling.api;version="[2.2,3)",org.apache.sling.api.request ;version="[2.2,3)",org.apache.sling.api.resource;version="[2.1,3)",org. apache.sling.api.servlets;version="[2.1,3)",org.apache.sling.jcr.api;ve rsion="[2.0,3)",org.gjt.xpp,org.jdom,org.jdom.input,org.osgi.framework; version="[1.5,2)",org.osgi.service.component;version="[1.1,2)",org.rela xng.datatype,org.slf4j;version="[1.5,2)",org.xml.sax,org.xml.sax.ext,or g.xml.sax.helpers,org.xmlpull.v1 Service-Component: OSGI-INF/serviceComponents.xml Tool: Bnd-1.50.0

Avatar

Level 10

Brian,

I see that dom4j and jaxen jars are included as part of your bundle.

You can verify the same by extracting your bundle locally and confirm that these jars are included in the bundle. If so the errors that are coming of different jars and not with dom4j or jaxen

Avatar

Correct answer by
Former Community Member

hi,

i find a solution to resolve this problem as below:

<Import-Package> com.sun.msv.*;resolution:=optional, nu.xom;resolution:=optional, org.gjt.xpp;resolution:=optional, org.jdom.*;resolution:=optional, org.relaxng.datatype;resolution:=optional, org.xmlpull.v1;resolution:=optional, * </Import-Package>

 

After deployment and it helps. But i not sure if it is right?

Anyway thanks a lot for your help.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----