-
1. Re: Problem with mysql db access
ffang Aug 23, 2011 6:08 AM (in response to neledv)Hi,
Add com.mysql.jdbc to Import-Package of your pom.xml.
Freeman
-
2. Re: Problem with mysql db access
neledv Aug 23, 2011 6:45 AM (in response to neledv)After adapting the import package, I can now deploy my project on the Fuse ESB without any issues.
However, when I try to run it, I get the following exception:
12:40:19,390 | ERROR | /filedropping/DB | DefaultErrorHandler | 77 - org.apache.camel.camel-core - 2.7.1.fuse-00-43 | Failed delivery for exchangeId: ID-PC016313-3491-1314093501954-12-72. Exhausted after delivery attempt: 1 caught: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3307/test
Why can my driver not be located ?
-
3. Re: Problem with mysql db access
ffang Aug 23, 2011 6:49 AM (in response to neledv)Hi,
I believe you hit a common issue when use JDBC driver in OSGi container.
Take a look at to get more details.
Also you need ensure the mysql driver you installed in OSGi container is OSGi friendly.
http://fusesource.com/forums/thread.jspa?messageID=9780☴
Freeman
-
4. Re: Problem with mysql db access
neledv Aug 23, 2011 7:30 AM (in response to neledv)Thanks for the links...
In the mean time I have created an additional bundle that does nothing but import the MySQL package to the commons-dbcp ServiceMix bundle.
But even when I deploy this to Fuse ESB, the problem still remains.
How can I check if mysql driver is OSGi friendly ?
-
5. Re: Problem with mysql db access
ffang Aug 23, 2011 8:36 AM (in response to neledv)Hi,
Sorry I can't understand what you mean by "I have created an additional bundle that does nothing but import the MySQL package to the commons-dbcp ServiceMix bundle."
You can use osgi:headers mysql_bundle_id to see if the OSGi metadata headers is there, this can tell you if it's OSGi friendly.
I think what you need do is make mysql as an OSGi fragment bundle and attach it to the spring-jdbc bundle(as you need pass driver name com.mysql.jdbc.Driver to org.springframework.jdbc.datasource.DriverManagerDataSource), so that class com.mysql.jdbc.Driver from mysql fragment is available to the spring-jdbc host.
Hope this helps.
Freeman
-
6. Re: Problem with mysql db access
neledv Aug 23, 2011 9:09 AM (in response to neledv)Hi,
Find attached the additional fragment bundle I had created before.
When I run osgi:headers command, I'm getting the following info back:
Sun Microsystems' JDBC Driver for MySQL (349)
-
Manifest-Version = 1.0
Ant-Version = Apache Ant 1.7.1
Built-By = mysqldev
Created-By = 1.5.0_22-b03 (Sun Microsystems Inc.)
Bundle-Vendor = Sun Microsystems Inc.
Bundle-Name = Sun Microsystems' JDBC Driver for MySQL
Bundle-SymbolicName = com.mysql.jdbc
Bundle-Classpath = .
Bundle-Version = 5.1.17
Bundle-ManifestVersion = 2
Import-Package =
javax.net,
javax.net.ssl;resolution:=optional;version="[1.0.1, 2.0.0)",
javax.xml.parsers,
javax.xml.stream,
javax.xml.transform,
javax.xml.transform.dom,
javax.xml.transform.sax,
javax.xml.transform.stax,
javax.xml.transform.stream,
org.w3c.dom,
org.xml.sax,
org.xml.sax.helpers;resolution:=optional,
javax.naming,
javax.naming.spi,
javax.sql,
javax.transaction.xa;resolution:=optional;version="[1.0.1, 2.0.0)",
com.mchange.v2.c3p0;resolution:=optional;version="[0.9.1.2, 1.0.0)",
org.jboss.resource.adapter.jdbc;resolution:=optional,
org.jboss.resource.adapter.jdbc.vendor;resolution:=optional
Export-Package =
com.mysql.jdbc;
uses:="com.mysql.jdbc.log,
javax.naming,
javax.net.ssl,
javax.xml.transform,
org.xml.sax";
version=5.1.17,
com.mysql.jdbc.jdbc2.optional;
uses:="com.mysql.jdbc,
com.mysql.jdbc.log,
javax.naming,
javax.sql,
javax.transaction.xa";
version=5.1.17,
com.mysql.jdbc.log;version=5.1.17,
com.mysql.jdbc.profiler;uses:=com.mysql.jdbc;version=5.1.17,
com.mysql.jdbc.util;uses:=com.mysql.jdbc.log;version=5.1.17,
com.mysql.jdbc.exceptions;version=5.1.17,
com.mysql.jdbc.exceptions.jdbc4;uses:=com.mysql.jdbc;version=5.1.17,
com.mysql.jdbc.interceptors;uses:=com.mysql.jdbc;version=5.1.17,
com.mysql.jdbc.integration.c3p0;version=5.1.17,
com.mysql.jdbc.integration.jboss;version=5.1.17,
com.mysql.jdbc.configs;version=5.1.17,
org.gjt.mm.mysql;version=5.1.17
Any other tips ?
-
springJDBC-mysql-fragment.zip 32.1 KB
-
-
7. Re: Problem with mysql db access
ffang Aug 23, 2011 10:32 AM (in response to neledv)Hi,
What I suggest means wrap the mysql driver as a fragment bundle, you needn't do
osgi:install -s mvn:mysql/mysql-connector-java/5.1.17
Anymore, just install this fragment wrapper bundle is fine.
So
1. The attached fragment bundle should have mysql dependency, you may need take a look at smx bundle repos[1] to get some concrete idea how to wrap a bundle
2. remove the Import-Pacakge com.mysql.jdbc from your mysql fragment bundle, as this bundle itself should have com.mysql.jdbc.
3. Ensure you already install spring-jdbc bundle, this is not default installed by FUSE ESB.
4. After you deploy springJDBC-mysql-fragment-1.0.0.jar, you need do
osgi:refresh spring-jdbc-bundle-id, then mysql fragment bundle could be pick up by spring-jdbc host.
If all is correct, you should be able to see something like
Fragments: 219
NBB :: Spring JDBC Fragment :: MySQL Driver (1.0.0)
Hosts: 215
when use osgi:list.
After that, you can deploy your camel router bundle.
https://svn.apache.org/repos/asf/servicemix/smx4/bundles/trunk/
Freeman
-
8. Re: Problem with mysql db access
neledv Aug 24, 2011 9:42 AM (in response to neledv)Hi,
I've managed to create the fragment bundle as you suggested.
Spring JDBC (3.0.5.RELEASE) Fragments: 368
NBB Fuse ESB:: Bundles :: mysql-connector-java (1.0.0) Hosts: 346
But when I deploy my sample route project afterwards, nothing happens.
(even a restart didn't help)
I don't see any errors and the bundle seems to be good installed as well.
-
9. Re: Problem with mysql db access
neledv Aug 24, 2011 9:46 AM (in response to neledv)When I check the details of my router bundle, I see the following:
A Camel Route (nbb-db-sample)Symbolic Name nbb-db-sample
Version 1.0.0
Bundle Location file:/D:/DEV/SOFTWARE/apache-servicemix-4.4.0-fuse-00-43/deploy/nbb-db-sample-1.0.0.jar
Last Modification Wed Aug 24 15:39:19 CEST 2011
Start Level 60
Exported Packages nbb.db.sample
Imported Packages com.mysql.jdbc,version=[5.1,6) -- Cannot be resolved
org.springframework.jdbc.datasource,version=[3.0,4) from org.springframework.jdbc (346)
Manifest Headers Bnd-LastModified: 1314193100527
Build-Jdk: 1.6.0_25
Built-By: devleen
Bundle-ManifestVersion: 2
Bundle-Name: A Camel Route
Bundle-SymbolicName: nbb-db-sample
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: nbb.db.sample
Import-Package: com.mysql.jdbc; version="[5.1, 6)", org.springframework.jdbc.datasource; version="[3.0, 4)"
Manifest-Version: 1.0
Tool: Bnd-1.15.0
-
10. Re: Problem with mysql db access
ffang Aug 24, 2011 9:55 AM (in response to neledv)Hi,
Notice this
Imported Packages com.mysql.jdbc,version=[5.1,6) -- Cannot be resolved
Your customer camel router bundle status isn't Active, right?
This error means your mysql fragment bundle didn't correctly export the package like com.mysql.jdbc.
Freeman