eclipsejdbcosgieclipselinkosgi-fragment

OSGi - running outside eclipse


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.


Solution

  • 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