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

Unable to use external jars in aem environment (OSGi)

Avatar

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

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

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
rasikawanjari
Level 2

03-04-2019

We have a third party jar which we want to use in our AEM project. We have added dependencies in pom files, it is resolving those jars only in eclipse but when it comes to Felix console it is not showing under the imported package and not giving any jars that have been added in dependencies. Hence, we are getting classnotfound exception while calling any methods from a jar.

Also, is it feasible if external project jar has the dependency on spring jar, can we include it in AEM as well?

Replies

Avatar

Avatar
Coach
Employee
jbrar
Employee

Likes

388 likes

Total Posts

869 posts

Correct Reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Coach
Employee
jbrar
Employee

Likes

388 likes

Total Posts

869 posts

Correct Reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile
jbrar
Employee

03-04-2019

I believe you need to add that jar to the OSGI console in order to use the services associated with that jar file.

You can include any jar within AEM as long as it is able to resolve the imported/exported bundle list mentioned in the metadata of that jar file

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,358 likes

Total Posts

3,228 posts

Correct Reply

918 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,358 likes

Total Posts

3,228 posts

Correct Reply

918 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

03-04-2019

worth to notice if jars are not osgi bundles.

You can not use jar directly in AEM, need to converted the Jar into bundle with help of the link "https://helpx.adobe.com/experience-manager/kb/ConvertAJarIntoOsgiBundle.html" , Now your bundle is ready to be uploaded into AEM through felix console.

Avatar

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

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

Avatar
Validate 1
Level 2
rasikawanjari
Level 2

Likes

6 likes

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
rasikawanjari
Level 2

04-04-2019

what to do in a scenario where the jar file has dependencies on other external jar files.I am facing this issue where i create the osgi bundle from normal jar and  upload it on AEM console but when I am trying to hit my servlet there it needs third party (spring)jars , so it giving
java.lang.NoClassDefFoundError: org/springframework/web/client/RestClientException.What can I do in this case?

Avatar

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

112 likes

Total Posts

394 posts

Correct Reply

64 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile

Avatar
Springboard
Level 7
Prince_Shivhare
Level 7

Likes

112 likes

Total Posts

394 posts

Correct Reply

64 solutions
Top badges earned
Springboard
Establish
Give Back 100
Boost 100
Validate 1
View profile
Prince_Shivhare
Level 7

04-04-2019

if you have added the dependency and jar is downloaded in your m2. repo then you need to manually put the jar in system/console.

upload the jar from m2 only.

Avatar

Avatar
Validate 1
Level 1
AshokPelluru
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
AshokPelluru
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
AshokPelluru
Level 1

04-04-2019

If that jar's not OSGi support, you should convert them to OSGi jars by simply adding the manifest file.

Here you go how to do that: How to Convert a jar File into an OSGi Bundle

Adobe Experience Manager (AEM/CQ5) : How to Convert a jar File into an OSGi Bundle

Avatar

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
Gaurav-Behl
MVP

Likes

248 likes

Total Posts

1,147 posts

Correct Reply

283 solutions
Top badges earned
Establish
Give back 300
Give Back 50
Give Back 5
Give Back 3
View profile
Gaurav-Behl
MVP

04-04-2019

If you want to use Spring in AEM for "some use case", then use Spring DM or Blueprint or similar container. One single jar file wouldn't work, you'd need to setup entire container.

If you are getting classnotfound exception, then package the jar (non-spring jars, packaging spring bundles won't work), and update your pom.xml's "maven-bundle-plugin" accordingly

Avatar

Avatar
Validate 1
Level 1
AshokPelluru
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
AshokPelluru
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
AshokPelluru
Level 1

04-04-2019

Hi @rasikawanjari

Make sure you should use only OSGi support spring versions.

Screen Shot 2019-04-04 at 4.54.14 PM.png