Java Junit:创建BOFactory实例时发生异常

Java Junit:创建BOFactory实例时发生异常,java,eclipse,junit,Java,Eclipse,Junit,我正在尝试在IID8.5上设置JUnit框架。但当我试图运行简单的JUnit测试用例时,我收到了运行时错误。(java.lang.NoClassDefFoundError:org.eclipse.core.runtime.RegistryFactory) 我正在使用JUnit4 **BOUtils.java中的代码** package com.wf.utils; import com.ibm.websphere.bo.BOFactory; import com.ibm.websphere.sca

我正在尝试在IID8.5上设置JUnit框架。但当我试图运行简单的JUnit测试用例时,我收到了运行时错误。(java.lang.NoClassDefFoundError:org.eclipse.core.runtime.RegistryFactory

我正在使用JUnit4

**BOUtils.java中的代码
**

package com.wf.utils;
import com.ibm.websphere.bo.BOFactory;
import com.ibm.websphere.sca.ServiceManager;
import com.ibm.websphere.sca.Service.*;

public class BOUtils {

/**
 * @param args
 */

public static void createBusinessObject()
{
    System.out.println("Create  Business Object");
    BOFactory boFactory = (BOFactory) new    ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
}
public static void main(String[] args) {
    // TODO Auto-generated method stub

}

}

**Code in JunitTest.java**

package JunitTest;
import junit.framework.TestCase;
import com.wf.utils.BOUtils;
import org.junit.Test;


   public class JunitTest extends TestCase {
   @Test
   public void testPersistCust()
  {
     System.out.println("testPersistCust");
     BOUtils.createBusinessObject();
  }
}  


**Exception Stack Trace**
 java.lang.NoClassDefFoundError: org.eclipse.core.runtime.RegistryFactory
at       org.eclipse.core.internal.runtime.InternalPlatform.getRegistry(InternalPlatform.java:671)
at org.eclipse.core.runtime.Platform.getExtensionRegistry(Platform.java:867)
at com.ibm.wsspi.sca.extensions.ServiceProviderRegistry.loadServiceProviders(ServiceProviderRegistry.java:167)
at com.ibm.wsspi.sca.extensions.ServiceProviderRegistry$1.run(ServiceProviderRegistry.java:88)
at java.security.AccessController.doPrivileged(AccessController.java:202)
at com.ibm.wsspi.sca.extensions.ServiceProviderRegistry.getServiceProviders(ServiceProviderRegistry.java:86)
at com.ibm.wsspi.sca.extensions.ServiceProviderRegistry.getServiceProvider(ServiceProviderRegistry.java:101)
at com.ibm.ws.sca.resources.loader.ClassLoaderRegistry.<clinit>(ClassLoaderRegistry.java:59)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at com.ibm.ws.sca.internal.container.impl.ContainerImpl.<clinit>(ContainerImpl.java:343)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at com.ibm.ws.sca.internal.container.impl.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:70)
at com.ibm.ws.sca.internal.container.Container.<clinit>(Container.java:111)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at com.ibm.ws.sca.internal.manager.impl.ServiceManagerImpl.<init>(ServiceManagerImpl.java:68)
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1325)
at com.ibm.websphere.sca.ServiceManager$InstanceCreator.create(ServiceManager.java:53)
at com.ibm.websphere.sca.ServiceManager$InstanceCreator.access$000(ServiceManager.java:43)
at com.ibm.websphere.sca.ServiceManager.<clinit>(ServiceManager.java:73)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at BOUtils.createBusinessObject(BOUtils.java:14)
at JunitTest.testPersistCust(JunitTest.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.RegistryFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:419)
at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:345)
at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
... 47 more
package com.wf.utils;
导入com.ibm.websphere.bo.bo工厂;
导入com.ibm.websphere.sca.ServiceManager;
导入com.ibm.websphere.sca.Service.*;
公共类花束{
/**
*@param args
*/
公共静态void createBusinessObject()
{
System.out.println(“创建业务对象”);
BOFactory BOFactory=(BOFactory)new ServiceManager().locateService(“com/ibm/websphere/bo/BOFactory”);
}
公共静态void main(字符串[]args){
//TODO自动生成的方法存根
}
}
**JunitTest.java中的代码**
包JunitTest;
导入junit.framework.TestCase;
导入com.wf.utils.BOUtils;
导入org.junit.Test;
公共类JunitTest扩展了TestCase{
@试验
public void testPersistCust()
{
System.out.println(“testpersistust”);
buutils.createBusinessObject();
}
}  
**异常堆栈跟踪**
java.lang.NoClassDefFoundError:org.eclipse.core.runtime.RegistryFactory
位于org.eclipse.core.internal.runtime.InternalPlatform.getRegistry(InternalPlatform.java:671)
位于org.eclipse.core.runtime.Platform.getExtensionRegistry(Platform.java:867)
位于com.ibm.wsspi.sca.extensions.ServiceProviderRegistry.loadServiceProviders(ServiceProviderRegistry.java:167)
位于com.ibm.wsspi.sca.extensions.ServiceProviderRegistry$1.run(ServiceProviderRegistry.java:88)
位于java.security.AccessController.doPrivileged(AccessController.java:202)
位于com.ibm.wsspi.sca.extensions.ServiceProviderRegistry.getServiceProviders(ServiceProviderRegistry.java:86)
位于com.ibm.wsspi.sca.extensions.ServiceProviderRegistry.getServiceProvider(ServiceProviderRegistry.java:101)
位于com.ibm.ws.sca.resources.loader.ClassLoaderRegistry。(ClassLoaderRegistry.java:59)
位于java.lang.J9VMInternals.initializeImpl(本机方法)
在java.lang.J9VMInternals.initialize(J9VMInternals.java:200)中
位于com.ibm.ws.sca.internal.container.impl.ContainerImpl.(ContainerImpl.java:343)
位于java.lang.J9VMInternals.initializeImpl(本机方法)
在java.lang.J9VMInternals.initialize(J9VMInternals.java:200)中
位于com.ibm.ws.sca.internal.container.impl.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:70)
位于com.ibm.ws.sca.internal.container.container.(container.java:111)
位于java.lang.J9VMInternals.initializeImpl(本机方法)
在java.lang.J9VMInternals.initialize(J9VMInternals.java:200)中
位于com.ibm.ws.sca.internal.manager.impl.ServiceManagerImpl.(ServiceManagerImpl.java:68)
位于java.lang.J9VMInternals.newInstanceImpl(本机方法)
位于java.lang.Class.newInstance(Class.java:1325)
在com.ibm.websphere.sca.ServiceManager$InstanceCreator.create上(ServiceManager.java:53)
位于com.ibm.websphere.sca.ServiceManager$InstanceCreator.access$000(ServiceManager.java:43)
位于com.ibm.websphere.sca.ServiceManager。(ServiceManager.java:73)
位于java.lang.J9VMInternals.initializeImpl(本机方法)
在java.lang.J9VMInternals.initialize(J9VMInternals.java:200)中
位于BOUtils.createBusinessObject(BOUtils.java:14)
在JunitTest.testPersistCust(JunitTest.java:50)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)中
位于java.lang.reflect.Method.invoke(Method.java:599)
位于org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
位于org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
位于org.junit.internal.runners.beforeandeafterrunner.runProtected(beforeandeafterrunner.java:34)
位于org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
位于org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
位于org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
位于org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
位于org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
位于org.junit.internal.runners.beforeandeafterrunner.runProtected(beforeandeafterrunner.java:34)
位于org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
位于org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
位于org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
位于org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
原因:java.lang.ClassNotFoundException:org.eclipse.core.runtime.RegistryFactory
位于java.net.URLClassLoader.findClass(URLClassLoader.java:419)
位于java.lang.ClassLoader.loadClass(ClassLoader.java:643)
位于sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:345)
位于java.lang.ClassLoader.loadClass(ClassLoader.java:609)
... 47多
我们将非常感谢您的帮助。如果需要其他信息,请告诉我

问候,,
RD

该异常告诉您,某个类对于运行该类的JVM不可用

简单的答案是:然后开始搜索该类。。。您可以找到这个,在这里您可以下载各种与eclipse相关的JAR

因此:尝试一下如果将org-eclipse-equinox-registry.jar添加到类路径中会发生什么


(这可能包含对正在发生的事情的解释)

该异常告诉您,某个类对于运行该类的JVM不可用

简单的答案是:然后是星星