OSGi - running outside eclipse

旧时模样 提交于 2019-12-11 08:23:27

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/9562943/osgi-running-outside-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!