Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Cannot resolve imported package in servlet bundle

Avatar

Avatar
Validate 1
Level 1
chrisd62525856
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
chrisd62525856
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
chrisd62525856
Level 1

15-10-2015

I am trying to use a 3rd party project (Jsoup) in my servlet. I have gone through the steps to build and deploy a bundle fragment plugin as outlined here:

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

This part works fine, I deploy it successfully via web console bundles and it has an "active" status. In my servlet's pom.xml I then include the dependency as such:

<dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.1</version>
</dependency>

I then build my servlet, do the maven clean install and deploy the servlet via the web console bundles. However, under imported packages I keep getting this error :

org.jsoup,version=[1.8,2) -- Cannot be resolved
org.jsoup.safety,version=[1.8,2) -- Cannot be resolved

Can anybody please help me out, its driving me nuts! Any advice would be appreciated

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-10-2015

The only thing that could possibly impact you is the version. You loaded version x and your bundle is looking for another version.

In the article, the bundle uses this version

<dependency>

           <!-- jsoup HTML parser library @ http://jsoup.org/ -->

            <groupId>org.jsoup</groupId>

            <artifactId>jsoup</artifactId>

            <version>1.7.3</version>

        </dependency>

You have to make sure that you place the same version in another bundle and deploy first. 

You can open the Manifest file in the OSGi bundle and remove version information:

Manifest-Version: 1.0
Bnd-LastModified: 1428330920949
Build-Jdk: 1.7.0_67
Built-By: scottm
Bundle-Description: Maven Multimodule project for aem.
Bundle-ManifestVersion: 2
Bundle-Name: aem Bundle
Bundle-SymbolicName: com.adobe.cq.jsoup.jsoupservice-bundle
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: com.adobe.cq.jsoup;uses:="org.jsoup,org.jsoup.select,org
 .jsoup.nodes,org.slf4j,org.osgi.framework,org.osgi.service.component";v
 ersion="1.0.0.SNAPSHOT"
Import-Package: org.jsoup,org.jsoup.nodes,org.jsoup.select,org.osgi.framework,org.osgi.service.component,org.slf4j
Service-Component: OSGI-INF/serviceComponents.xml
Tool: Bnd-1.50.0

 

 Notice that version is removed. Now I can place the bundle into an Active state.

Also look at the article referenced in this thread. The AEM JSOUP app is now attached to the article.       

Answers (9)

Answers (9)

Avatar

Avatar
Boost 5
Level 3
sureshr19072451
Level 3

Likes

18 likes

Total Posts

31 posts

Correct Reply

5 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile

Avatar
Boost 5
Level 3
sureshr19072451
Level 3

Likes

18 likes

Total Posts

31 posts

Correct Reply

5 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile
sureshr19072451
Level 3

25-06-2018

Avatar

Avatar
Affirm 1
Employee
deep_kamal
Employee

Likes

0 likes

Total Posts

2 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Employee
deep_kamal
Employee

Likes

0 likes

Total Posts

2 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
deep_kamal
Employee

05-11-2017

you need to install jsoup jar also as a bundle , just faced this problem and then installed Maven Repository: org.jsoup » jsoup » 1.10.3  , worked for me.

Avatar

Avatar
Validate 1
Level 1
ykumarreddy
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
ykumarreddy
Level 1

Like

1 like

Total Posts

11 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
ykumarreddy
Level 1

22-02-2017

HI,

 

I followed exactly same as you specified in the  document. But I still getting below error.  In my bundle I added dependency as 

 

         <dependency>
            <!-- jsoup HTML parser library @ http://jsoup.org/ -->
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.7.3</version>
        </dependency>

 

When I ran the maven command In menifest file I am seeing import and 

The Import-package section is have the version number as below.  Could you please help how can I fix this issue.

 

Import-Package: com.adobe.cq.sightly;version="[2.5,3)",com.day.cq.i18n;v
 ersion="[5.4,6)",com.day.cq.wcm.api;version="[1.17,2)",com.day.cq.wcm.a
 pi.designer;version="[5.8,6)",com.day.cq.wcm.msm.api;version="[5.9,6)",
 com.delltechnologies.constants,com.delltechnologies.service,javax.injec
 t;version=1,javax.jcr;version="[2.0,3)",javax.jcr.observation;version="
 [2.0,3)",javax.servlet,org.apache.commons.lang3;version="[3.0,4)",org.a
 pache.commons.lang3.builder;version="[3.0,4)",org.apache.sling.api;vers
 ion="[2.3,3)",org.apache.sling.api.request;version="[2.4,3)",org.apache
 .sling.api.resource;version="[2.9,3)",org.apache.sling.api.scripting;ve
 rsion="[2.2,3)",org.apache.sling.commons.json;version="[2.0,3)",org.apa
 che.sling.commons.osgi;version="[2.4,3)",org.apache.sling.jcr.api;versi
 on="[2.3,3)",org.jsoup;version="[1.7,2)",org.jsoup.nodes;version="[1.7,
 2)",org.jsoup.select;version="[1.7,2)
",org.osgi.service.component;versi
 on="[1.1,2)",org.slf4j;version="[1.5,2)"

g.jsoup,version=[1.7,2) -- Cannot be resolved
org.jsoup.safety,version=[1.7,2) -- Cannot be resolved

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-10-2015

I will setup a connect session with you. The reply I give you at top is correct. You are loading incorrect version. I will help you through that. 

Avatar

Avatar
Validate 1
Level 1
chrisd62525856
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
chrisd62525856
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
chrisd62525856
Level 1

15-10-2015

Works like a charm thanks a lot for the help! The problem was with the import-package/export-package section. I appreciate the help and effort

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

15-10-2015

Hi Chris,

Please make sure the jsoup bundle you have deployed on OSGi follows the same artifacts and version.

<dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.1</version>
</dependency>

Also, add the <scope>provided</scope> to the dependency and see if it helps

Avatar

Avatar
Validate 1
Level 1
chrisd62525856
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
chrisd62525856
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
chrisd62525856
Level 1

15-10-2015

Thanks for the reply, much appreciated. I have followed the steps outlined but the problem is still not resolved. I have done the export process on the jsoup jar and loaded the OSGi bundle fragment into AEM as per the instructions. This part works the fine. The 3rd party jar is in active state in AEM. The problem is that for some reason my servlet bundle does not pick it up once I upload it to AEM...

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-10-2015

YOu are missing the JSOUP JAR in the OSGi container. You need to place the JSOUP JAR into an OSGi bundle, deploy to AEM, and place into an active state.

Here is an AEM community article that works with JSOUP - your exact use case:

https://helpx.adobe.com/experience-manager/using/html-parser-service.html

Remember that all third party JAR files that your custom AEM services use must be loaded into an OSGi bundle,deployed, and placed into an active state. 

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,078 likes

Total Posts

3,117 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,078 likes

Total Posts

3,117 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

15-10-2015

Hi,

when you have deployed jsoup as a fragment bundle (which you attached the system bundle) you don't need to add a dependency to it. I am wondering why to deployed the jsoup package as a fragment bundle to the OSGI container instead providing the jsoup JAR as a regular bundle.

kind regards,
Jörg