1

I have been working on getting my OSGi application to run outside eclipse. It has certainly wasn't as easy as I thought out would be certainly not just a case of running java -jar org.eclipse.osgi_3.7.1.jar and installing the plugins.

I'm hoping this is the last problem

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/

This works fine in Eclipse. I have a persistence bundle and several fragmentation bundles that I load depending on the database type that I require. I then also have another bundle with the database JDBC drivers. In eclipse I can run it, out side eclipse I have been trying everything including using class loaders to load the Driver

Activator.context = bundleContext;

Class.forName("com.mysql.jdbc.Driver");

try {
    context.getBundle().loadClass("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}

Any idea what to look at? From what I can see my setups are identical and both have the same bundles running.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Kris
  • 963
  • 1
  • 13
  • 22

1 Answers1

2

Does your bundle import the package com.mysql.jdbc?

Read the following wiki page for some background on why this might work inside Eclipse but not in a proper OSGi environment: http://wiki.osgi.org/wiki/Why_does_Eclipse_find_javax.swing_but_not_Felix%3F

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
  • Strange thing that I noticed running outside of eclipse is I had to add other imports to the Bundles like javax.net for a different bundle that does FTP. The persistence bundle in eclipse doesn't need to import com.mysql.jdbc but I added it to try and resolve the problem but to no avail – Kris Mar 05 '12 at 10:51
  • Although I think I just worked out what it is. In eclipse I have a target platform that includes a bunch of JARs. I'm guessing the issue is that not all of these are available when running stand alone – Kris Mar 05 '12 at 10:52
  • I had many extra unneeded JARs in my eclipse target environment. I have deleted those and tested my app. It still works fine. I now have all of the jars installed in my external version but still getting the same error. grrr – Kris Mar 05 '12 at 12:19