Expand my Community achievements bar.

SOLVED

JSOUP not getting resolved

Avatar

Level 4

Hello All - I am getting the below error because of that, OSGi bundle is not starting.

 

org.jsoup,version=[1.9,2) -- Cannot be resolved
org.jsoup.nodes,version=[1.9,2) -- Cannot be resolved
org.jsoup.select,version=[1.9,2) -- Cannot be resolved

 

Basically I just wanted to include JSOUP jar that should be embedded in my project's bundle. I tried adding the below to include the JSOUP in the bundle. I am using latest archetype (23), Can someone advise on how to include the embed the bundle.

Also please note that, I have already placed the required JSOUP jar in the "libs" folder.


<properties>
<system.dependencies>${project.basedir}/libs</system.dependencies>
</properties>

<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${system.dependencies}/jsoup-1.9.2.jar</systemPath>
</dependency>


<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.1.0</version>
<inherited>true</inherited>
<configuration>
<instructions>
<Bundle-SymbolicName>com.test.core</Bundle-SymbolicName>
<Sling-Model-Packages>
com.test.core.internal.impl.models
</Sling-Model-Packages>
<Embed-Dependency>jsoup</Embed-Dependency>
</instructions>
</configuration>
</plugin>

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
16 Replies

Avatar

Community Advisor

Hi @s1101v,

 

The below error says that the JSOUP bundle is not resolved. To resolve the issue, check my answer here.

 

If you are trying to include JSOUP Jar, AEM does not support it. You need to install a bundle into AEM. Use this dependency in your pom and follow the steps mentioned in the above link.

 

<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

Avatar

Level 4
@Kiran_Vedantam - I have already tried this as well. This jar needs to be included in my project's bundle so I added <Embed-Dependency> in core module POM but it is not including in the bundle.

Avatar

Community Advisor
Hi s1101v, please add it in the install folder of the instance to check if it gets installed

Avatar

Level 4
@Kiran_Vedantam - I have installed the bundle in the instance as well. I still see issues with the JSOUP bundle. I have extracted the project bundle as well, the included jar is not available.

Avatar

Community Advisor

@s1101v 

In Export-Package add org.jsoup.*, it should work.

<dependency>
    <groupId>org.jsoup</groupId>
    <artifactId>jsoup</artifactId>
    <version>1.9.2</version>
</dependency>
<Export-Package>org.jsoup.*</Export-Package>

Avatar

Community Advisor

@s1101vDid you remove Embed-Dependency? If no remove it. Add remove system scope also. Check in Exported Packages list.

jsoup.PNG

Avatar

Level 4
@Anudeep_Garnepudi - I have already removed scope, systempath and also embed-dependency as well. I see the issue in "Import Packages" section, so I have added <Import-Package>org.jsoup.*</Import-Package>. The bundle is not getting resolved.

Avatar

Community Advisor
You don't need to add in Import-Package, add it in Export-Package and try once

Avatar

Correct answer by
Community Advisor

Avatar

Level 4
@arunpatidar - I have already gone through this link. If I add/install the jsoup jar separately in console, the bundle gets resolved but I don't want to install the required bundles separately. Basically I just wanted to include it in project bundle itself. I am getting the error in "Import Packages" section.

Avatar

Community Advisor

you can simple copy the bundle jar in your java core project or copy this bundle from core to ui.app similar to app bundle.

example : https://github.com/arunpatidar02/aemaacs-aemlab/blob/932349cb9fb5f201c53107317e0eeb5c33651e2a/all/po... 



Arun Patidar

Avatar

Level 2

Hi @s1101v 

How did you resolve this?

 

Avatar

Level 4

I faced similar issue and I am able to solve this. This is because your core bundle is looking for the jsoup bundle and it is missing in out of all of your 600 or 700 available bundles in your aem. So what we have to do is make this bundle available in your AEM.

 

1. Add jsoup(or any other third party dependencies) dependency in main and core pom.xml.

2. Go to core pom.xml and find the plug-in with artifact id bnd-maven-plugin. Now edit the plugin like below

 

<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<executions>
<execution>
<id>bnd-process</id>
<goals>
<goal>bnd-process</goal>
</goals>
<configuration>
<bnd><![CDATA[
Import-Package: javax.annotation;version=0.0.0,org.jsoup.*;version=1.8.1,*
]]></bnd>
</configuration>
</execution>
</executions>
</plugin>

 

3. Now save the core pom.xml

4. Now you have to embed this package in ui.all module pom.xml in org.apache.jackrabbit plugin groupID

<embedded>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<target>/apps/wknd-packages/application/install</target>
</embedded>

Note: Change your target folder accordingly to your project.

5. You are done now and deploy the code to your AEM. Now you can see jsoup jar got added into your target folder and if you go to bundles console and search for jsoup then you can see jsoup bundle got added into your aem bundles.

6. Now you can't see jsoup cannot resolve error in your core bundle.

 

If above steps not works for you then you manually download the related jar present in /apps target folder and try to upload via bundles console. If you get any errors while upload means that your bundle is missing Bundle-SymbolicName or Import-Package or other bundle manifest headers might be missing. In this case you need to manually edit the downloaded bundle via eclipse like converting the jar to osgi bundle in eclipse. There is some process to convert jar into bundle in eclise, google it. While in converting process add the required manifest headers like Import-Package/Export-Package etc.. In Import-Package section if nothing is present in your manifest file then you need to add the required pacakges(take the ref from existing bundle manifest file in your AEM). Putting same version of your jsoup dependency for Import Package is very Important.

 

See sample core pom.xml: https://github.com/adobe/aem-guides-wknd/blob/main/core/pom.xml

See sample all pom.xml: https://github.com/adobe/aem-guides-wknd/blob/main/all/pom.xml

Avatar

Level 3

Hi @Uppari_Ramesh ,

I have tried the above method but im getting build failure in all module.

Could you please help fixing this.

Error : 
val : 2023-12-31 (com.carrybag:carry-bag.all:1.0.0-SNAPSHOT)
[ERROR] The analyser found the following errors for author and publish :
[ERROR] [api-regions-exportsimports] com.carrybag:carry-bag.core:1.0.0-SNAPSHOT: Bundle carry-bag.core:1.0.0-SNAPSHOT is importing package(s) [org.jsoup.select, org.jsoup, org.jsoup.nodes] in start level 20 but no bundle is exporting these for that start level. (com.carrybag:carry-bag.all:1.0.0-SNAPSHOT) 

I have posted the same with more info : https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/build-issue-while-adding-j...

Avatar

Level 1

I added the dependencies on pom.xml of core (as I have my servlets inside core)
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
</dependency>
and ran below command on the path \.m2\repo1\m3-3.5.4\org\jsoup\jsoup\1.14.3.
mvn install:install-file -Dfile=jsoup.jar(or add path to jsoup.jar) -DgroupId=org.jsoup -DartifactId=jsoup -Dversion=1.14.3 -Dpackaging=jar

the error above is resolved.
Give it a try.