Embedding external jar is not working in AEMaaCS | Community
Skip to main content
Mario248
Level 7
February 13, 2023
Solved

Embedding external jar is not working in AEMaaCS

  • February 13, 2023
  • 4 replies
  • 2932 views

 

I want to add aws-sdk-java jar as part of code deployment in AEMaaCS hence I am using embed feature to add external jar but the jar file is not including during build in /apps/myproject-packages/application/install location.
 
Used embed in <project>\all module

 

<plugin> <groupId>org.apache.jackrabbit</groupId> <artifactId>filevault-package-maven-plugin</artifactId> <extensions>true</extensions> <configuration> <group>com.myproject.aem</group> <packageType>container</packageType> <!-- skip sub package validation for now as some vendor packages like CIF apps will not pass --> <skipSubPackageValidation>true</skipSubPackageValidation> <embeddeds> <embedded> <groupId>com.myproject.aem</groupId> <artifactId>aem-myproject.ui.apps</artifactId> <type>zip</type> <target>/apps/myproject-packages/application/install</target> </embedded> <embedded> <groupId>com.myproject.aem</groupId> <artifactId>aem-myproject.core</artifactId> <target>/apps/myproject-packages/application/install</target> </embedded> <embedded> <groupId>com.myproject.aem</groupId> <artifactId>aem-myproject.ui.config</artifactId> <type>zip</type> <target>/apps/myproject-packages/application/install</target> </embedded> <embedded> <groupId>com.myproject.aem</groupId> <artifactId>aem-myproject.ui.content</artifactId> <type>zip</type> <target>/apps/myproject-packages/content/install</target> </embedded> <!-- external jar--> <embedded> <groupId>software.amazon.awssdk</groupId> <artifactId>aws-sdk-java</artifactId> <target>/apps/myproject-packages/application/install</target> </embedded> </embeddeds> </configuration> </plugin>

 

Added aws-sdk-java dependency in  <project>\all module as below 

 

<dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>aws-sdk-java</artifactId> </dependency>

 

Added below in dependency in parent module

 

<dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>aws-sdk-java</artifactId> <version>2.19.33</version> <scope>provided</scope> </dependency>

 

I have refered below articles - 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by nitesh_kumar-1

Hi @mario248 ,

 

I think you need to create an OSGi bundle of the non-OSGi JAR dependencies, you can do it using the maven-bundle-plugin where you would also need to set the export as well.

 

Check the below article, it has a similar use case as yours.

https://myaemlearnings.blogspot.com/2021/08/embedding-third-party-dependencyosgi.html 

 

Hope that helps!

 

Regards,

Nitesh

4 replies

ArpitVarshney
Community Advisor
Community Advisor
February 13, 2023

Hi @mario248 

The above steps look fine but I didn't see the dependency used in the core module where you want to use the corresponding classes. You might need to add the dependency in the core module pom.xml along with the parent pom.

<dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>aws-sdk-java</artifactId> </dependency>


Also, If you still see the issue, can you share the screenshot of the system/console/bundle where we can see the error?

Regards,

Arpit Varshney

Mario248
Mario248Author
Level 7
February 13, 2023

I have already adde this in core module dependency. Sorry, I forgot to mention this before. 

 

I see below error while deploying to AEM,

 

Could not start bundle aem-myproject.core [622]. Reason: {}. Will retry.
org.osgi.framework.BundleException: Unable to resolve aem-myproject.core [622](R 622.69😞 missing requirement [aem-myproject.core [622](R 622.69)] osgi.wiring.package; (osgi.wiring.package=software.amazon.awssdk.auth.credentials) Unresolved requirements: [[aem-myproject.core [622](R 622.69)] osgi.wiring.package; (osgi.wiring.package=software.amazon.awssdk.auth.credentials)]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4368)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2281)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)
at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:97) [org.apache.sling.installer.core:3.9.0.B002]
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.doExecuteTasks(OsgiInstallerImpl.java:914) [org.apache.sling.installer.core:3.9.0.B002]
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:749) [org.apache.sling.installer.core:3.9.0.B002]
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:298) [org.apache.sling.installer.core:3.9.0.B002]
at java.base/java.lang.Thread.run(Thread.java:834)
 
Seems like I need to below dependency  as well ,
 
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>auth</artifactId>
<version>2.20.2</version>
</dependency>
 
Should this be just as dependency or embed to AEM? Any suggestion ?
ArpitVarshney
Community Advisor
Community Advisor
February 13, 2023

@mario248 It seems like the jar you mentioned above is depending on this jar which is not resolving as a bundle. Could you please add this jar as well in all/pom.xml like the one you mentioned in the problem statement and follow the same steps for this one and see if it works?

Regards,

Arpit Varshney

arunpatidar
Community Advisor
Community Advisor
February 13, 2023
Mario248
Mario248Author
Level 7
February 13, 2023

I already used  <embedded> to include external jar except <type> attribute. I guess the default value is jar if we dont provide.

arunpatidar
Community Advisor
Community Advisor
February 13, 2023

software.amazon.awssdk.auth.credentials is a jar or a bundle? if it is a jar then it will not be resolved in aem.

Arun Patidar
Ritesh_Mittal
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 13, 2023

Hi @mario248 ,

 

 

 

If you are stuck with JAR which you want as bundle then you can just convert the JAR to bundle and then use it. Please refer below video-

 

https://youtu.be/EXyvsIknCLI

 

Thanks

Ritesh Mittal

nitesh_kumar-1
Adobe Employee
nitesh_kumar-1Adobe EmployeeAccepted solution
Adobe Employee
February 13, 2023

Hi @mario248 ,

 

I think you need to create an OSGi bundle of the non-OSGi JAR dependencies, you can do it using the maven-bundle-plugin where you would also need to set the export as well.

 

Check the below article, it has a similar use case as yours.

https://myaemlearnings.blogspot.com/2021/08/embedding-third-party-dependencyosgi.html 

 

Hope that helps!

 

Regards,

Nitesh