How to use json-path as bundle embeded jars? | Community
Skip to main content
Level 4
July 10, 2021
Solved

How to use json-path as bundle embeded jars?

  • July 10, 2021
  • 1 reply
  • 1296 views

Does anyone has an osgi service bundle that include a few dependency jar files? I want to use json-path in my osgi bundle, however, json-path need a few maven dependencies: json-smart, asm, etc. I tried to convert each jar as separate osgi bundle jar or embed all the jars in my bundle, none of them is an easy task and no working solutions. How you guys embed the dependency jars in the osgi bundle? Why these kind of simple stuff in maven and npm is so difficult and messy in osgi? in maven and npm, it is so straightforward to include as much as needed utility jar or npm module. That's why the osgi concept is dying except inside AEM? ^_^

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 DavidZhang

Finally, I make the json-path works in my workflow steps osgi bundle. It's hell lots of work. You need to put all your maven dependencies in pom.xml, even it is explicitly referred. then you need to export all the packages felix need to lookup, and put the maven bundles in the build list:

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.2</version>
<extensions>true</extensions>
<configuration>

<instructions>
<Export-Package>net.minidev.asm;version="2.4.7", org.apache.tapestry5.json, org.codehaus.jettison.json;version="1.4.1"</Export-Package>
<Embed-Dependency>
json-path;
json-smart;
accessors-smart;
asm;
org.apache.tapestry5.json;
jettison;
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>


<!-- for the json-path to embed into bundle -->
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.4.7</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>accessors-smart</artifactId>
<version>2.4.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.ow2.asm/asm -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.1</version>
</dependency>
<dependency>
<groupId>org.apache.tapestry5</groupId>
<artifactId>json</artifactId>
<version>5.2.5</version>
<scope>system</scope>
<systemPath>${project.basedir}/dependencies/tapestry-json-5.2.5.jar</systemPath>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.jettison/jettison -->
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.4.1</version>
</dependency>


All I need is a json-path dependency in maven, but see how many things I need to configure just to resolve the class path issue.
 

 

1 reply

DavidZhangAuthorAccepted solution
Level 4
July 10, 2021

Finally, I make the json-path works in my workflow steps osgi bundle. It's hell lots of work. You need to put all your maven dependencies in pom.xml, even it is explicitly referred. then you need to export all the packages felix need to lookup, and put the maven bundles in the build list:

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>5.1.2</version>
<extensions>true</extensions>
<configuration>

<instructions>
<Export-Package>net.minidev.asm;version="2.4.7", org.apache.tapestry5.json, org.codehaus.jettison.json;version="1.4.1"</Export-Package>
<Embed-Dependency>
json-path;
json-smart;
accessors-smart;
asm;
org.apache.tapestry5.json;
jettison;
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>


<!-- for the json-path to embed into bundle -->
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>2.4.7</version>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>accessors-smart</artifactId>
<version>2.4.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.ow2.asm/asm -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.1</version>
</dependency>
<dependency>
<groupId>org.apache.tapestry5</groupId>
<artifactId>json</artifactId>
<version>5.2.5</version>
<scope>system</scope>
<systemPath>${project.basedir}/dependencies/tapestry-json-5.2.5.jar</systemPath>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.jettison/jettison -->
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.4.1</version>
</dependency>


All I need is a json-path dependency in maven, but see how many things I need to configure just to resolve the class path issue.