Hi All,
I'm trying to add JSOUP to my maven project in order to do that i followed the below steps.
I have read few articles and tried to embed the JSOUP JAR in AEM but its not working.
Could you please provide an step by step instruction for adding 3rd party library (JSOUP) in AEM Maven Project.
Core POM.xml:
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.17.2</version> <scope>provided</scope>
</dependency>
[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.nodes, org.jsoup, org.jsoup.select] in start level 20 but no bundle is exporting these for that start level. (com.carrybag:carry-bag.all:1.0.0-SNAPSHOT)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Carry Bag 1.0.0-SNAPSHOT:
[INFO]
[INFO] Carry Bag .......................................... SUCCESS [ 0.865 s]
[INFO] Carry Bag - Core ................................... SUCCESS [01:11 min]
[INFO] Carry Bag - UI Frontend ............................ SUCCESS [04:17 min]
[INFO] Carry Bag - Repository Structure Package ........... SUCCESS [ 4.149 s]
[INFO] Carry Bag - UI apps ................................ SUCCESS [ 36.522 s]
[INFO] Carry Bag - UI content ............................. SUCCESS [ 26.174 s]
[INFO] Carry Bag - UI config .............................. SUCCESS [ 1.516 s]
[INFO] Carry Bag - All .................................... FAILURE [01:45 min]
[INFO] Carry Bag - Integration Tests ...................... SKIPPED
[INFO] Carry Bag - Dispatcher ............................. SKIPPED
[INFO] Carry Bag - UI Tests ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:30 min
[INFO] Finished at: 2024-04-06T22:00:07+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.adobe.aem:aemanalyser-maven-plugin:1.4.10:project-analyse (aem-analyser) on project carry-bag.all: One or more feature analyser(s) detected feature error(s), please read the plugin log for more details -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :carry-bag.all
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Hari,
I too faced this jsoup issue long back on that time I added the dependencies in main pom file
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
<scope>provided</scope>
</dependency>
and added this one core pom file
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<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.osgi.framework,*
-includeresource: jsoup*.jar;lib:=true
]]></bnd>
</configuration>
</execution>
</executions>
</plugin>
So try out this one will works for your case
Thanks
Nandheswara
Hi @HariDo,
This should work fine. I tried it in a project which is using jsoup with the same dependency and hopefully I am not getting any error. Please share the mvn command you are using and make sure you doing "Load maven changes" when you add the dependency in core's pom by clicking the icon
or pressing ctrl+shift+O (if you are using intellij). For other compilers you can google how to load maven changes.
Hi @HariDo
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.17.2</version>
</dependency>
mvn clean install -PautoInstallPackage
Check the Maven build output for any errors related to the JSOUP dependency. If there are no errors, the JSOUP JAR file should be included in your AEM package.
If you encounter the error you mentioned in your question, it means that the AEM Analyser plugin detected that your bundle is importing packages that are not exported by any other bundle. To fix this error, you can add the following instructions to your bundle's pom.xml file:
<instructions>
<Export-Package>
<!-- Export all packages in your bundle -->
*
</Export-Package>
<Import-Package>
<!-- Import the required packages from JSOUP -->
org.jsoup.nodes,
org.jsoup,
org.jsoup.select,
*
</Import-Package>
</instructions>
This will export all packages in your bundle and import the required packages from JSOUP. Make sure to include the *
wildcard character to import all other required packages.
Hi @Raja_Reddy
I have added the dependency in my core pom.xml file
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.17.2</version>
</dependency>
after adding dependency i cleaned and build my project using "mvn clean" then " mvn clean install -PautoInstallPackage -DskipTests=true" and got a build failure in all module as mentioned in the post description.
then as you mentioned i have added the instructions to my core pom.xml file.
<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,*
]]></bnd>
<instructions>
<Export-Package>
com.carrybag.core,
*
</Export-Package>
<Import-Package>
org.jsoup,
org.jsoup.nodes,
org.jsoup.select,
*
</Import-Package>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
I'm still getting the same error, Could you please check and let me know if I'm missing anything.
Error:
[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.nodes, org.jsoup, org.jsoup.select] in start level 20 but no bundle is exporting these for that start level. (com.carrybag:carry-bag.all:1.0.0-SNAPSHOT)
This is because of the aemanalyser-maven-plugin.
Please refer to the below links -
Embedding Third party dependency/OSGi bundle in AEM application hosted in AEMasCS
Hope this helps!
@HariDo , Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community
Hi Hari,
I too faced this jsoup issue long back on that time I added the dependencies in main pom file
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
<scope>provided</scope>
</dependency>
and added this one core pom file
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<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.osgi.framework,*
-includeresource: jsoup*.jar;lib:=true
]]></bnd>
</configuration>
</execution>
</executions>
</plugin>
So try out this one will works for your case
Thanks
Nandheswara
This Worked thank you @Nandheswara
@HariDo I trust you found the AEM community useful. We are excited to see you back as either a learner or a mentor. The community is strengthened by SMEs like you. Please invite your AEM peers to join and contribute. Happy AEM learning!
Views
Replies
Total Likes
Views
Likes
Replies