我有一个在 Equinox 上运行的 osgi 应用程序。这就是在引导类中启动捆绑包的方式。
String[] equinoxArgs = new String[]{"-console"};
EclipseStarter.setInitialProperties(getInitialProperties());
BundleContext context = EclipseStarter.startup(equinoxArgs, null);
List<URL> urls = getListOfBundleUrls();
for(URL url: urls) {
Bundle bundle = context.installBundle(url.toString());
bundle.start();
}
我的应用程序中有一个捆绑包中有一个启动方法。这个方法应该在所有的bundle 都被启动来运行应用程序之后被调用。当在引导类中调用该方法时,它会给出一个错误,指出在类路径中找不到某些类。这是堆栈跟踪。
Initial SessionFactory creation failed.org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver com.mysql.jdbc.Driver class not found
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.cc.erp.platform.dbutils.services.BasicDBManager.buildSessionFactory(BasicDBManager.java:26)
at com.cc.erp.platform.dbutils.services.BasicDBManager.<clinit>(BasicDBManager.java:12)
at com.cc.erp.platform.dbutils.DBAgent.getNewCRUDService(DBAgent.java:19)
at com.cc.erp.reload.core.WebService.forQuery(WebService.java:51)
at com.cc.erp.reload.ui.CommandLineUserInterface.<init>(CommandLineUserInterface.java:27)
at com.cc.erp.helius.bootstrap.Bootstrap.launchHelius(Bootstrap.java:41)
at com.cc.erp.helius.bootstrap.Bootstrap.main(Bootstrap.java:22)
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver com.mysql.jdbc.Driver class not found
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:107)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
包 com.mysql.jdbc 在 osgi 运行时中导出。但它不在引导类路径中。我相信应该从框架本身调用这个方法。请告诉我最好的方法。