Im trying to connect database in JFUSE project. I've included com.mysql.jdbc dependency in pom file and project build runs fine. But then I encounter this annoying problem. When I try to install the bundle to OSGi, installation failed with following error:
Unable to start bundle mvn:com.info.demo/demo-rest/1.0: Unresolved const raint in bundle com.info.demo.rest [363]: Unable to resolve 363.0: missing requirement [363.0] osgi.wiring.package; (osgi.wiring.package=com.mysql.jdbc)
I tried all available solution from SO, but they didnt solve the issue. While I was trying to find cause of error, I saw warning in dependency declaration of mysql in IDE that says:
Maven Dependency is not OSGi ready
So, I guess main reason is that my dependency is not ready for OSGi container. Can any one help me how to make maven dependency OSGi ready?
Below is my pom.xml code:
<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">
***Project specific declarations here***
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Fragment-Host>org.springframework.jdbc</Fragment-Host>
<Import-Package>com.mysql.jdbc</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.mysql.jdbc</groupId>
<artifactId>com.springsource.com.mysql.jdbc</artifactId>
<version>5.1.6</version>
</dependency>
***Other Dependencies***
</dependencies>
Edit: I followed Christain suggestion and it work great. But I need to add other dependencies which are not OSGi ready.
I went through installing non OSGi dependencies to FUSE server. And also wrapping dependencies but didnt solved issue.
Please help me with details solution, Im really stuck here.
With some days of searching I finally found the simplest solutions. Non OSGi bundle can be made OSGi ready by just using this simple osgi wrap command in Karaf or ServiceMix terminal:
osgi:install wrap:mvn:org.jdbi/jdbi/2.70
Dependency will be installed in Fuse server which can be verified by using command.
osgi:list
Now just add dependencies in pom.
Idea will still warn you dependency is not OSGi ready, just ignore it.
Finally import needed package in maven bundle plugin and you are done.
Hope this will help somebody in future.