I have spent a few days trying to understand how to deploy as OSGI bundle and need some help. I am using servicemix 4.5.2, maven 3.1.0 and maven-bundle-plugin 2.4.0. I have added the following tags in my .pom
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
My bundle builds and when I deploy into servicemix, I get a series of BundleExceptions. I iteratively add the missing packages to my pom until I hit a wall. "Missing requirement package; (package=com.ibm.ejs.ras)". The immediate issue is that I can't find the ras.jar to download or in a Maven repository. But I think the larger issue is that I am doing something incorrectly that is resulting in my having to manually track down transitive dependencies.
I have dug around and saw that common issues were resolved by using the pre-bundled versions from Spring and Fuse. The Fuse repository appears to have vanished and the Spring one seems to be sun-setting and doesn't have all the .jars I need. I also tried the bundleall maven-bundle-plugin which I saw on another post the goal is now deprecated). That resulted in "Error generating OSGi bundle for project org.beanshell:bsh-core: aQute.bnd.osgi.Descriptors$PackageRef cannot be cast to java.lang.String".
I have used previous (pre-OSGI) versions of servicemix and camel and have high regard for both products. However, I am losing steam (and work time) trying to get over the OSGI hurdle and Mule is becoming more attractive. If anyone has some insights, they would be greatly appreciated.
Thank-you.
My pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.abc</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>myartifact</artifactId>
<packaging>bundle</packaging>
<name>myartifact</name>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mail</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-dao</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.35.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Export-Package>com.mycompany.abc.myartifact</Export-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
com.ibm.ejs.ras is probably an optional dependency to one of the JARS you have bundled in.
You would update your Import-Package to filter out the offending package.
<Import-Package>!com.ibm.ejs.ras, *</Import-Package>.
Also:
Embed-Dependency uses Bundle-Classpath under the hood. I'd defer to the creator of the tool that is enabling you to do this: http://www.aqute.biz/Bnd/FAQ#bundleclasspath
I would definitely agree that Embed-Dependency is definitely not necessary in this case, considering you are using ServiceMix which comes with 90% of what you are needing in this case anyway. The rest can be installed within ServiceMix itself using mvn: or wrap:mvn: style-urls. (which is only dbcp and lang3 and selenium)