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

Avatar

Avatar
Validate 1
Level 1
bartek887
Level 1

Like

1 like

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
bartek887
Level 1

Like

1 like

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
bartek887
Level 1

18-03-2021

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

572 likes

Total Posts

727 posts

Correct reply

239 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

572 likes

Total Posts

727 posts

Correct reply

239 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile
Vijayalakshmi_S
MVP

19-03-2021

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)

Answers (4)

Answers (4)

Avatar

Avatar
Validate 1
Level 1
bartek887
Level 1

Like

1 like

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
bartek887
Level 1

Like

1 like

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
bartek887
Level 1

22-03-2021

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>

Avatar

Avatar
Springboard
Level 4
bilal_ahmad
Level 4

Likes

66 likes

Total Posts

108 posts

Correct reply

16 solutions
Top badges earned
Springboard
Validate 10
Validate 1
Ignite 1
Establish
View profile

Avatar
Springboard
Level 4
bilal_ahmad
Level 4

Likes

66 likes

Total Posts

108 posts

Correct reply

16 solutions
Top badges earned
Springboard
Validate 10
Validate 1
Ignite 1
Establish
View profile
bilal_ahmad
Level 4

19-03-2021

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.

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

18-03-2021

@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>

 

Avatar

Avatar
Level 1
Tian-Z
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
Tian-Z
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
Tian-Z
Level 1

26-03-2021

@bartek887 

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