2

我正在使用 WebSphere 8 的可嵌入 EJB 容器为我的 EJB 和 JUnit4 编写一些单元测试。我的 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/hpel/HpelHelper 类的 jar。

这是我的类路径:

C:\workspaces\irad8\JSF2.0Test\MyEJBPrj\ejbModule;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.wccm.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.emf.jar;
C:\Program Files\IBM\WebSphere\AppServer\dev\JavaEE\6.0\j2ee.jar;
C:\Program Files\IBM\WebSphere\AppServer\lib\mail-impl.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.runtime.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.ejbportable.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.admin.core.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.admin.services.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.portletcontainer.jar;
C:\Program Files\IBM\WebSphere\AppServer\lib\bootstrap.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.sib.server.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.sip.container.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.sip.interface.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.jsf.myfaces.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.webcontainer.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.wsadie\marshall.jar;
C:\Program Files\IBM\WebSphere\AppServer\lib\ffdcSupport.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.wsadie\wsatlib.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.runtime.dist.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\com.ibm.mq.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\com.ibm.mq.headers.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\com.ibm.mq.pcf.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\com.ibm.mq.jmqi.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\com.ibm.mq.connector.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\com.ibm.mq.commonservices.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\dhbcore.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\org.eclipse.emf.common.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\org.eclipse.emf.commonj.sdo.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\org.eclipse.emf.ecore.change.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\org.eclipse.emf.ecore.sdo.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\org.eclipse.emf.ecore.xmi.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\org.eclipse.emf.ecore.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.wsdl4j.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.wsfp.main.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.jackson.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.xlxp.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.jaxrs.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\javax.j2ee.jaxrs.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.jaxrs.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.vajava.jar;
C:\Program Files\IBM\WebSphere\AppServer\lib\rsadbutils.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.jpa.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.commonj-twm.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.prereq.soap.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\org.apache.tuscany.sca.api.jar;
C:\Program Files\IBM\WebSphere\AppServer\dev\sca\1.0\sca_api.jar;
C:\Program Files\IBM\WebSphere\AppServer\dev\xml\xmlapi.jar;
C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.batch.runtime.jar;
C:\Program Files\IBM\WebSphere\AppServer\tivoli\tam\PD.jar;
C:\Program Files\IBM\WebSphere\AppServer\installedConnectors\wmq.jmsra.rar\com.ibm.mqjms.jar;
C:\Program Files (x86)\IBM\SDPShared\plugins\org.junit_4.8.1.v4_8_1_v20100427-1100\junit.jar;
C:\Program Files (x86)\IBM\SDPShared\plugins\org.hamcrest.core_1.1.0.v20090501071000.jar;
C:\Program Files\IBM\WebSphere\AppServer\runtimes\com.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/
4

3 回答 3

2

WebSphere 可嵌入 EJB 容器中包含的 RAS 不使用 HPEL。此错误消息暗示您的类路径中的某些 JAR 正在使用不同的 RAS。您应该删除所有 WebSphere JAR,除了C:\Program Files\IBM\WebSphere\AppServer\runtimes\com.ibm.ws.ejb.embeddableContainer_8.0.0.‌​jar.

于 2013-03-16T14:58:03.897 回答
0

我能够摆脱这个问题是取消选中项目方面的运行时选择。

我在 JUint 中的配置如下

地图属性 = new HashMap(); properties.put(EJBContainer.PROVIDER, "com.ibm.websphere.ejbcontainer.EmbeddableContainerProvider"); 文件 jar = new File("./target/test_ejb.jar"); properties.put(EJBContainer.MODULES, jar); //可嵌入容器中配置的数据库属性 properties.put("com.ibm.websphere.embeddable.configFileName", "./target/test-classes/embeddable.properties"); EJBContainer ec = EJBContainer.createEJBContainer(properties);

于 2013-03-25T14:57:57.597 回答
0

连接到 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
  • 杰斯.jar
于 2015-01-20T14:23:12.007 回答