我有一个从jar文件(testlibrary.jar)调用代码的OSGI包(awesome.test)。我已将该捆绑包作为Liberty功能(awesome.test.feature)包含在内,并将其安装在WebSphere Application Server Liberty Profile V8.5.5上。我也有一个OSGI包(awesometest),它是OSGI应用程序(awesometest.app)的一部分,它有一个Activator类。OSGI应用程序在使用Liberty功能时获取NoClassDefFoundError
Here is a picture of my workspace setup
我想要做的是通过awesome.test方法testlibrary.jar,其中包括在其构建路径testlibrary.jar调用方法。我的awesome.test.feature适用于运行在我的Liberty服务器上的任何应用程序。我希望我的应用程序能够使用该功能通过我在awesome.test中提供的内容来访问testlibrary.jar中的功能。我不希望OSGI应用程序直接从testlibrary.jar导入包。
CWWKZ0402E:尝试应用awesometest.app安装到OSGi框架时产生一束异常,当我在服务器上运行的应用程序出现在二进制日志
以下错误。来自OSGi框架的错误文本是:awesometest的awesometest.Activator.start()中的异常。
调试问题,发现此异常被抛出:
抛出java.lang.ClassNotFoundException:从TestLibraryRunner.java在awesome.test testlibrary.test.TestAPI
来源:
package awesome.test;
import testlibrary.test.TestAPI;
public class TestLibraryRunner {
public static void runNonLibTest() {
System.out.println("No Library code is being called");
}
public static void runLibTest() {
TestAPI ta = new TestAPI("This is a message.");
ta.display();
}
}
请注意,从OSGI应用程序调用runNonLibTest()时将起作用。从OSGI应用程序调用runLibTest中的TestAPI代码将导致上述错误。在awesometest从Activator.java
来源:MANIFEST.MF
public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
System.out.println("Starting...");
TestLibraryRunner.runNonLibTest();
TestLibraryRunner.runLibTest();
System.out.println("Finishing...");
}
public void stop(BundleContext context) throws Exception {
System.out.println("Stopping...");
}
}
来源awesometest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: awesometest
Bundle-SymbolicName: awesometest
Bundle-Version: 1.0.0
Bundle-Activator: awesometest.Activator
Import-Package: awesome.test,
org.osgi.framework
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: awesometest
总之,我的OSGi应用程序无法从罐子中构建路径触及代码包括在我的Liberty功能中。我在这里错过了一些基本的东西吗?我试图做甚至可能吗?
感谢