Including third part jar files in aemaacs | Community
Skip to main content
Community Advisor
September 9, 2024
Solved

Including third part jar files in aemaacs

  • September 9, 2024
  • 2 replies
  • 772 views

I have included third party jar file in my project, I got the following error 

[xxxxx ] in start level 20 but no bundle is exporting these for that start level

I found following article to fix this 

https://aemconcepts.com/aem-osgi/use-3rd-party-api-or-jar-or-dependency-in-aem/

adding 

-include-resource:cq-dam-processor-nui-1.1.840.jar -classpath:cq-dam-processor-nui-1.1.840.jar 
in core pom bnd-process section fixed above error. Bundle is active however all the services are in satisfied state
 
Clicking on component shows me this
Reference osgi.ds.satisfying.conditionSatisfied
Service Name: org.osgi.service.condition.Condition
Target Filter: (osgi.condition.id=true)
Cardinality: 1..1
Policy: dynamic
Policy Option: reluctant
 
There are multiple errors in error.log,  it seems bundle is not able to find the service classes  
 09.09.2024 01:12:37.892 *WARN* [FelixLogListener] org.apache.sling.engine.impl.filter.ServletFilterManager bundle org.apache.sling.engine:2.15.16 (567)[org.apache.sling.engine.impl.filter.ServletFilterManager(3528)] : Could not get service from ref [javax.servlet.Filter]
09.09.2024 01:12:37.967 *ERROR* [FelixLogListener] Events.Framework.org.apache.sling.engine FrameworkEvent ERROR (org.apache.felix.log.LogException: org.osgi.framework.ServiceException: Service factory exception: javax/servlet/Filter)
org.apache.felix.log.LogException: org.osgi.framework.ServiceException: Service factory exception: javax/servlet/Filter
org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: org/apache/sling/api/resource/ResourceResolver
Attaching logs as well
If anyone come across this issue pls provide suggestions on how to resolve?
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 sarav_prakash

Hi @mshaji ,

The secret sauce is, 

 

Add 

-conditionalpackage: org.apache.sling.servlethelpers.*,com.demo.package.*

inside the bnd-process plugin goal. So your bnd-process of parent pom.xml should look like this:

 

<plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> <version>${bnd.version}</version> <executions> <execution> <id>bnd-process</id> <goals> <goal>bnd-process</goal> </goals> <configuration> <bnd> <![CDATA[ Bundle-Category: ${componentGroupName} -exportcontents: ${removeall;${packages;VERSIONED};${packages;CONDITIONAL}} -noextraheaders: true -snapshot: SNAPSHOT -conditionalpackage: org.apache.sling.resource.filter.* Bundle-DocURL: -plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin -plugin org.apache.sling.bnd.models.ModelsScannerPlugin ]]> </bnd> </configuration> </execution> </executions> </plugin>

An excellant article explaining difference between conditionalpackage and includeresource is here - https://myaemlearnings.blogspot.com/2021/12/embed-third-party-dependency-using-bnd.html

 

Just adding the -conditionalpackage to your plugin should solve your issue. 

2 replies

sarav_prakash
Community Advisor
sarav_prakashCommunity AdvisorAccepted solution
Community Advisor
September 10, 2024

Hi @mshaji ,

The secret sauce is, 

 

Add 

-conditionalpackage: org.apache.sling.servlethelpers.*,com.demo.package.*

inside the bnd-process plugin goal. So your bnd-process of parent pom.xml should look like this:

 

<plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> <version>${bnd.version}</version> <executions> <execution> <id>bnd-process</id> <goals> <goal>bnd-process</goal> </goals> <configuration> <bnd> <![CDATA[ Bundle-Category: ${componentGroupName} -exportcontents: ${removeall;${packages;VERSIONED};${packages;CONDITIONAL}} -noextraheaders: true -snapshot: SNAPSHOT -conditionalpackage: org.apache.sling.resource.filter.* Bundle-DocURL: -plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin -plugin org.apache.sling.bnd.models.ModelsScannerPlugin ]]> </bnd> </configuration> </execution> </executions> </plugin>

An excellant article explaining difference between conditionalpackage and includeresource is here - https://myaemlearnings.blogspot.com/2021/12/embed-third-party-dependency-using-bnd.html

 

Just adding the -conditionalpackage to your plugin should solve your issue.