Hi,
I am following the tutorial Integrating SOLR with Adobe Experience Manager to integrate with SOLR 8.8 from AEM 6.5.7. The tutorial uses maven-scr-plugin to create a bundle where I have a project based on Adobe archetype that uses bnd-maven-plugin.
I added the following dependencies to the parent pom, and same (without version) to the core sub project pom.
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.solr-solrj</artifactId>
<version>8.7.0_1</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.6.2</version>
</dependency>
When I build the project the bundle is installed with all dependencies resolved (I uploaded org.apache.servicemix.bundles.solr-solrj bundle manually to the felix console for now).
But when I try to run the simple code snippet like
HttpSolrClient client = new HttpSolrClient.Builder(solrUrl)
.build();
SolrInputDocument documentsolr = new SolrInputDocument();
documentsolr.addField("path", path);
documentsolr.addField("time", System.nanoTime());
client.add(documentsolr);
client.commit();
I am getting NoClassDefFoundError for class from zookeper dependency
java.lang.NoClassDefFoundError: org/apache/zookeeper/server/ByteBufferInputStream at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:698) at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:266) at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:248)
Could you please advise how can I make sure that the required class in in the classpath of my bundle. Seems there is more to configure in bnd-maven-plugin then in the maven-scr-plugin and I can not get it right
Thanks !
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @bartek887,
At times for some dependencies, using -conditionalpackage with bnd-maven-plugin might not resolve the dependencies completely.
I suggest to create/build and deploy the OSGI bundle standalone using maven-bundle-plugin which has below instructions responsible for including all the compile and run time dependencies.
<Embed-Dependency>*;inline=true</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
https://myaemlearnings.blogspot.com/2021/02/createbuild-and-install-osgi-bundle-of.html (have created a post related to this last month)
Class ByteBufferInputStream is available at compile time but not at runtime. Try Embedding all dependencies(at least runtime ) in bnd-maven-plugin configuration.
<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[
Embed-Dependency: *;scope=compile|runtime
]]></bnd>
</configuration>
</execution>
</executions>
</plugin>
Views
Replies
Total Likes
Hey @bartek887 try adding this in your bundle pom.xml :
<executions>
<execution>
<id>bnd-process</id>
<goals>
<goal>bnd-process</goal>
</goals>
<configuration>
<bnd><![CDATA[
-conditionalpackage: org.apache.zookeeper.*
..
..
]]></bnd>
</configuration>
</execution>
</executions>
I hope this helps
Thanks,
Bilal.
Views
Replies
Total Likes
Hi @bartek887,
At times for some dependencies, using -conditionalpackage with bnd-maven-plugin might not resolve the dependencies completely.
I suggest to create/build and deploy the OSGI bundle standalone using maven-bundle-plugin which has below instructions responsible for including all the compile and run time dependencies.
<Embed-Dependency>*;inline=true</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
https://myaemlearnings.blogspot.com/2021/02/createbuild-and-install-osgi-bundle-of.html (have created a post related to this last month)
Thanks @Vijayalakshmi_S for your help. I hoped I will be able to make it work without creating custom dependency but it seems this is not the way to go. I followed your blog post and created a custom bundle with the following pom (working on AEM 6.5.7)
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.osgi.wrapped</groupId>
<artifactId>org.apache.zookeeper-osgi</artifactId>
<packaging>bundle</packaging>
<name>OSGi wrapper for Apache Zookeper</name>
<version>3.6.2</version>
<dependencies>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.6.2</version>
</dependency>
<dependency>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>4.2.1</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Vendor>${project.organization.name}</Bundle-Vendor>
<Import-Package>
org.apache.commons.lang.*
</Import-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<_exportcontents>
org.apache.zookeeper.*
</_exportcontents>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Have you figured it out? Could you please post your solution. Many thanks
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies