You run into a well known issue that jdbc driver generally doesn't work in OSGi container, basically it's caused by Class.forName(), take a look my blog to get more details.
Thanks for the reply. Your link was quite useful. It did lead me to this: http://fusesource.com/docs/esbent/7.1/esb_deploy_osgi/ch12s04.html
When I followed the steps there to identify the missing dependencies (which involves enabling "dynamic import", It did not show any dependency on my jdbc library. When I started the package, i get the same class not found error.
If I add the class to the dependencies in the POm file, I get the follwing error:
Unable to resolve 307.0: missing requirement osgi.wiring.package; (osgi.wiring.package=oracle.jdbc.OracleDriver)
So perhaps my problem is that the class I think is in my JDBC bundle is not actually in there??
You mentioned that you already OSGi-fied the oracle JDBC driver, you can use
to see if the driver bundle OSGi header is correct. Basically check it Export-Package part
The osgi:headers command showed me the Export-Package names, and I included that as a DynamicImport-Package in my POM file, and it resolved the problem.
As an aside, I am getting quite frustrated with the amount of effort required wrestling with OSGI, dependencies etc. My progress on solving the 'real-world' problemis almost non-existant. I am startign to doubt whether I should persist with FuseESB/Camel, or look for something else...
You are not the only one having problems with the OSGi deployment model being too complicated and hard to work with for the common developer.
Fuse ESB offers a much easier deployment model on top of OSGi called FAB. Check out this blog with has links to more material and videos
And Fuse ESB Enterprise ships with a number of examples in the /examples directory that are all FAB examples, with instructions how to deploy and use.
I suggest to take a look at that.
Thanks for the reply.
I have installed my package as a FAB, but now I am getting the original 'class not found' trying to use my JDBC driver. Do i need to put something into my POM file to tell it that my driver is in a bundle (in OSGi)?
Without FAB, I was able to tell my bundle to 'dynamic import' the JDBC drivers from my bundleised JDBC driver jar. Are you able to explain how i can perform this using FAB?
The dynamic import was an instruction to the maven-bundle-plugin.
PS: I am still surprised at how difficult it appears to be to get a JDBC connection (using a jar file) in camel/FuseESB.
If the JDBC driver is OSGi compliant, then it would work out of the box; for the pure OSGi base.
And yeah I have been pushing on for years to make this easier. Suggested to have a special dir / command to install those JDBC drivers or other resource bundles in a easier way and have your app be able to use them. Or have some way ala a JEE server with a web console to setup a connection pool or whatnot.
But with FAB you just add the JDBC driver dependency to your maven project, and do not have to worry at all. You don't even have to add that felix-bundle-plugin and fight with what the h*** you have to add as import/export/dynamic stuff and what not. Just do a pure Maven project and be happy and productive.
It's only if you want to share a dependency with FAB you would need to define the maven scope as or use some FAB meta-data. And FAB knows about the Karaf features so when you depend on Camel / CXF / ActiveMQ etc it uses the Karaf features as first choice.
Anyway I think there is also a verbose syntax to the osgi:install command you can do to add that dynamic import when installing. But the syntax is hard to remember and not so easy to google.
Not sure if i'm taking this thread off into too much of a tangent, but using FAB is giving me basically the same results (class not found error). If i inspect the FAB bundle, it says I have no dependencies. This doesn't seem right to me.
No embedded/non-shared dependencies
No shared/bundle dependencies required
No additional features repositories required
My POM.xml has the JDBC class listed as a dependency (and I have use mvn install:install-file to put it into my maven repository.