-
1. Re: hooking up JDBC datasource
ffang Mar 14, 2013 3:16 AM (in response to paulc8712)Hi,
This generally means you have two copy of javax.sql.DataSource in your container, but loaded by different classloaders.
Most likely your customer bundle embed jar which have javax.sql.DataSource or some other bundle also export it.
You can use "packages:exports |grep javax.sql"
to check it out, it should be from system bundle 0, and your customer bundle should Import-Package javax.sql, also your customer bundle shouldn't embed javax.sql.DataSource .
Freeman
-
2. Re: hooking up JDBC datasource
paulc8712 Mar 14, 2013 8:22 PM (in response to ffang)I checked which packages export 'javax.sql' using packages:exports |grep javax.sql.
It turns out package 0, and my JDBC driver wrapper package both do.
I changed my package to not export javax.sql, and I still have the same issue.
I then checked which packages include the SimpleDriverDataSource class:
FuseESB:admin@root> osgi:find-class SimpleDriverDataSource
Spring JDBC (253)
org/springframework/jdbc/datasource/SimpleDriverDataSource.class
org/springframework/jdbc/datasource/embedded/SimpleDriverDataSourceFactory$1.class
org/springframework/jdbc/datasource/embedded/SimpleDriverDataSourceFactory.class
Spring ORM (255)
org/springframework/jdbc/datasource/SimpleDriverDataSource.class
OpenJPA Aggregate Jar (256)
org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.class
MyApplication (267)
org/springframework/jdbc/datasource/SimpleDriverDataSource.class
Could this be a problem?
-
3. Re: hooking up JDBC datasource
ffang Mar 14, 2013 9:16 PM (in response to paulc8712)Yes, it could be
At least MyApplication bundle shouldn't embed Spring JDBC.
Freeman
-
4. Re: hooking up JDBC datasource
paulc8712 Mar 14, 2013 9:18 PM (in response to ffang)This is no doubt showing my ignorance here - what what do you mean by 'embed'? A dependency listed in the POM file?
-
5. Re: hooking up JDBC datasource
paulc8712 Mar 19, 2013 2:09 AM (in response to paulc8712)I seem to have my JDBC working .. however getting it started is convoluted, and I do not understand why what I do works.
install my fuse package (packaged as a 'jar') via FAB with the -s option (to start):
osgi:install -s fab:mvn:com.mycompany/myapplication/1.0.0-SNAPSHOT
this fails. however if i do not sopeciify the -s option, the following steps do not work.
dev:dynamic-import <ID>
resolve <ID>
packages:imports <ID>
This now lists my JDBC bundle as an import. I can now start the package.
start <ID>
FWIW, I am specifying the <DynamicImport-Package>, but it seems to be making no difference. I will obviously need to come pack and work out why this is happening, but I have a basic JDBC connection working, so I nede to move on to try and get some productive development done. I am expecting some pain with JPA, which is my next step.