我使用WebSphere 8的可嵌入EJB容器用JUnit4为我的EJB编写一些单元测试。我的IDE是RAD 8。
下面是我的简单测试代码片段: <>以前
Map properties = new HashMap();
properties.put(EJBContainer.PROVIDER,
"com.ibm.websphere.ejbcontainer.EmbeddableContainerProvider");
EJBContainer ec = EJBContainer.createEJBContainer(properties);
之前我得到NoClassDefFoundError:
java.lang.NoClassDefFoundError: com/ibm/ejs/ras/hpel/HpelHelper
at com.ibm.ejs.ras.RasHelper.getThreadId(RasHelper.java:1760)
at com.ibm.ejs.ras.RasEvent6$1.initialValue(RasEvent6.java:101)
at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:152)
at java.lang.ThreadLocal.get(ThreadLocal.java:142)
at com.ibm.ejs.ras.RasEvent6.<init>(RasEvent6.java:292)
at com.ibm.ejs.ras.MessageEvent6.<init>(MessageEvent6.java:203)
at com.ibm.ejs.ras.Tr.fireMessageEvent(Tr.java:1555)
at com.ibm.ejs.ras.Tr.warning(Tr.java:1207)
at com.ibm.ws.naming.java.javaNameSpaceImpl.localNameSpaceInit(javaNameSpaceImpl.java:347)
at com.ibm.ws.naming.java.javaNameSpaceImpl.init(javaNameSpaceImpl.java:267)
at com.ibm.ws.naming.java.javaURLInitialContextFactory.getInitialContext(javaURLInitialContextFactory.java:156)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:247)
at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:318)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:348)
at javax.naming.InitialContext.internalInit(InitialContext.java:286)
at javax.naming.InitialContext.<init>(InitialContext.java:211)
at com.ibm.ejs.csi.DefaultComponentMetaData.initializeJavaNameSpace(DefaultComponentMetaData.java:150)
at com.ibm.ejs.csi.DefaultComponentMetaData.<init>(DefaultComponentMetaData.java:122)
at com.ibm.ejs.csi.DefaultComponentMetaData.<clinit>(DefaultComponentMetaData.java:94)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)
at com.ibm.ws.threadContext.ComponentMetaDataAccessorImpl.<init>(ComponentMetaDataAccessorImpl.java:59)
at com.ibm.ws.threadContext.ComponentMetaDataAccessorImpl.<clinit>(ComponentMetaDataAccessorImpl.java:54)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)
at com.ibm.ws.threadContext.JavaNameSpaceAccessorImpl.<init>(JavaNameSpaceAccessorImpl.java:56)
at com.ibm.ws.threadContext.JavaNameSpaceAccessorImpl.<clinit>(JavaNameSpaceAccessorImpl.java:48)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)
at com.ibm.websphere.ejbcontainer.EmbeddableContainer.initNaming(EmbeddableContainer.java:353)
at com.ibm.websphere.ejbcontainer.EmbeddableContainer.initialize(EmbeddableContainer.java:454)
at com.ibm.websphere.ejbcontainer.EmbeddableContainer.open(EmbeddableContainer.java:428)
at com.ibm.websphere.ejbcontainer.EmbeddableContainer.newContainer(EmbeddableContainer.java:382)
at com.ibm.websphere.ejbcontainer.EmbeddableContainerProvider.createEJBContainer(EmbeddableContainerProvider.java:75)
我在任何地方都找不到类为com/ibm/ejs/ras/hpell/hpelhelper的jar。
这是我的类路径:
C:workspacesirad8JSF2.0TestMyEJBPrjejbModule;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.wccm.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.emf.jar;
C:Program FilesIBMWebSphereAppServerdevJavaEE6.0j2ee.jar;
C:Program FilesIBMWebSphereAppServerlibmail-impl.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.runtime.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.ejbportable.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.admin.core.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.admin.services.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.portletcontainer.jar;
C:Program FilesIBMWebSphereAppServerlibbootstrap.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.sib.server.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.sip.container.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.sip.interface.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.jsf.myfaces.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.webcontainer.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.wsadiemarshall.jar;
C:Program FilesIBMWebSphereAppServerlibffdcSupport.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.wsadiewsatlib.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.runtime.dist.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rarcom.ibm.mq.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rarcom.ibm.mq.headers.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rarcom.ibm.mq.pcf.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rarcom.ibm.mq.jmqi.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rarcom.ibm.mq.connector.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rarcom.ibm.mq.commonservices.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rardhbcore.jar;
C:Program FilesIBMWebSphereAppServerpluginsorg.eclipse.emf.common.jar;
C:Program FilesIBMWebSphereAppServerpluginsorg.eclipse.emf.commonj.sdo.jar;
C:Program FilesIBMWebSphereAppServerpluginsorg.eclipse.emf.ecore.change.jar;
C:Program FilesIBMWebSphereAppServerpluginsorg.eclipse.emf.ecore.sdo.jar;
C:Program FilesIBMWebSphereAppServerpluginsorg.eclipse.emf.ecore.xmi.jar;
C:Program FilesIBMWebSphereAppServerpluginsorg.eclipse.emf.ecore.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.prereq.wsdl4j.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.wsfp.main.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.prereq.jackson.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.prereq.xlxp.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.prereq.jaxrs.jar;
C:Program FilesIBMWebSphereAppServerpluginsjavax.j2ee.jaxrs.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.jaxrs.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.prereq.vajava.jar;
C:Program FilesIBMWebSphereAppServerlibrsadbutils.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.jpa.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.prereq.commonj-twm.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.prereq.soap.jar;
C:Program FilesIBMWebSphereAppServerpluginsorg.apache.tuscany.sca.api.jar;
C:Program FilesIBMWebSphereAppServerdevsca1.0sca_api.jar;
C:Program FilesIBMWebSphereAppServerdevxmlxmlapi.jar;
C:Program FilesIBMWebSphereAppServerpluginscom.ibm.ws.batch.runtime.jar;
C:Program FilesIBMWebSphereAppServertivolitamPD.jar;
C:Program FilesIBMWebSphereAppServerinstalledConnectorswmq.jmsra.rarcom.ibm.mqjms.jar;
C:Program Files (x86)IBMSDPSharedpluginsorg.junit_4.8.1.v4_8_1_v20100427-1100junit.jar;
C:Program Files (x86)IBMSDPSharedpluginsorg.hamcrest.core_1.1.0.v20090501071000.jar;
C:Program FilesIBMWebSphereAppServerruntimescom.ibm.ws.ejb.embeddableContainer_8.0.0.jar;
/C:/Program Files/IBM/SDP/configuration/org.eclipse.osgi/bundles/1486/1/.cp/;
/C:/Program Files/IBM/SDP/configuration/org.eclipse.osgi/bundles/1484/1/.cp/;
/C:/Program Files/IBM/SDP/configuration/org.eclipse.osgi/bundles/1485/1/.cp/
包含在WebSphere可嵌入EJB容器中的RAS不使用HPEL。此错误消息暗示类路径上的某些JAR正在使用不同的RAS。您应该删除除C:Program FilesIBMWebSphereAppServerruntimescom.ibm.ws.ejb.embeddableContainer_8.0.0.jar
以外的所有WebSphere jar。
我能够摆脱这个问题是从项目方面取消检查运行时选择。
我在jint中的配置如下
Map属性= new HashMap();properties.put (EJBContainer。提供者,"com.ibm.websphere.ejbcontainer.EmbeddableContainerProvider");File jar = new File("./target/test_ejb.jar");properties.put (EJBContainer。模块,jar);//可嵌入容器中配置的DB属性。configFileName"、"。/目标/测试类/embeddable.properties");EJBContainer ec = EJBContainer. createejbcontainer (properties);
当连接到FileNet P8时,我也得到了这个错误。我需要:
- com.ibm.ws.ejb.embeddableContainer_8.5.0.jar
- com.ibm.ws.ejb.thinclient_8.5.0.jar
- ibmorb.jar
- com.ibm.ws.emf.jar
- j2ee.jar
- Jace.jar