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

SOLVED

Issue with configuring solr dependencies with bnd plugin (solr - zookeper)

bartek887
Level 1
Level 1

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 ! 🙂 

AEM 6.5 bnd-maven-plugin osgi Solr
1 Accepted Solution
Vijayalakshmi_S
Correct answer by
Community Advisor
Community Advisor

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)

View solution in original post

7 Replies
Anudeep_Garnepudi
Community Advisor
Community Advisor

@bartek887 

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>

 

bartek887
Level 1
Level 1
Unfortunately this did not help with the issue, class still can not be found.
bilal_ahmad
Level 5
Level 5

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.

Vijayalakshmi_S
Correct answer by
Community Advisor
Community Advisor

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)

View solution in original post

bartek887
Level 1
Level 1

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>
Tian-Z
Level 1
Level 1

@bartek887 

Have you figured it out? Could you please post your solution. Many thanks