2016-05-13 196 views
0

我試圖從Jboss(6.4 EAP)到WebSphere(7.x)進行EJB調用。 我有一個從WebSphere(WAS)到WAS的工作示例,但是,相同的位置和查找名稱返回名稱未找到異常。我目前正在將一個作爲WAR部署的Web應用程序內部進行測試,並將其作爲Jboss進行測試。Jboss(6.4 EAP)到WebSphere(7.x)

我沒有在web.xml或jboss-web.xml中定義EJB(我不相信我需要它)。 WebSphere中的EJB版本是2.1。

Properties env = new Properties(); 
env.put(Context.PROVIDER_URL, "corbaloc::example.test.com:11000"); 
InitialContext ctx = new InitialContext(env); 
Object obj= ctx.lookup("cell/clusters/MyEJBHome12Cluster/MyEJBHome"); 

以上拋出一個的NameNotFoundException:

javax.naming.NameNotFoundException: cell/clusters/MyEJBHome12Cluster/MyEJBHome -- service jboss.naming.context.java.cell.clusters."MyEJBHome12Cluster"."MyEJBHome" 
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104) 
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197) 
    at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:243) 
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183) 
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179) 
    at javax.naming.InitialContext.lookup(InitialContext.java:411) 
    at javax.naming.InitialContext.lookup(InitialContext.java:411) 
    at com.test.ejbClient.getRemoteConnection(ejbClient.java:192) 
    at com.test.ejbClient.runIt(ejbClient.java:77) 
    at com.test.TestRemoteEJB.doGet(TestRemoteEJB.java:59) 

我也試圖利用太陽工廠:com.sun.jndi.cosnaming.CNCtxFactory

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); 

這產生了相似的結果:

javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0] 
    at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:61) 
    at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:502) 
    at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:541) 
    at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:519) 
    at javax.naming.InitialContext.lookup(InitialContext.java:411) 
    at javax.naming.InitialContext.lookup(InitialContext.java:411) 
    at com.test.ejbClient.getRemoteConnection(ejbClient.java:192) 
    at com.test.ejbClient.runIt(ejbClient.java:77) 
    at com.test.TestRemoteEJB.doGet(TestRemoteEJB.java:59) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) 
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0 
    at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72) 
    at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:251) 
    at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:488) 

以上嘗試使用以下網站:Reference Link First

然後我嘗試使用IBM客戶端JAR,只是爲了查看我是否可以接到呼叫。我跟着這個網站:Reference Link 2

我加了2瓶:

  • com.ibm.ws.ejb.thinclient_8.5.0.jar
  • com.ibm.ws.orb_8.5.0.jar

我還添加了所有包含EJB類和存根類的jar。我使用了com.ibm.websphere.naming.WsnInitialContextFactory的工廠。它看起來了EJB罰款,但PortableRemoteObject.narrow通話過程中,它無法用

java.lang.ClassCastException: com.test._MyEJBHome_Stub cannot be cast to org.omg.CORBA.Object 

我懷疑我將能夠使用WAS罐子反正我不得不使用Java 1.8上運行,從而贏得」 t與我上面的客戶端jar一起工作,當Jboss應該能夠這樣做時,我也不喜歡在JBoss內部使用IBM jar。

+0

你可能知道,在默認情況下的WebSphere IIOP偵聽2809,不是11000。如果這是沒有問題的,或許真的該網頁上會有所幫助:https://www.ibm.com/support/ knowledgecenter/SSAW57_7.0.0/com.ibm.websphere.nd.doc/info/ae/ae/rnam_example_prop3.html –

+0

更正我以前的評論:通常你通過引導端口查找InitialContext,默認是2809,而不是11000. If這不是問題,也許這個頁面上的內容會有所幫助:https://www.ibm.com/support/knowledgecenter/SSAW57_7.0.0/com.ibm.websphere.nd.doc/info/ae/ae/ rnam_example_prop3.html此頁面可能也有幫助:https://www.ibm.com/support/knowledgecenter/was_beta/com.ibm.websphere.base.doc/ae/rnam_example_prop1.html –

+0

我遇到了同樣的問題問題。你能告訴我你是如何解決的嗎? – Stony

回答

1

我們確實最終找到了解決這個問題的方法。在查找JBoss時需要有一組神奇的角色。以前,提供者URL和JNDI是分開的。現在,它們都在查找字符串中,如下所示。此外,沒有其他參數添加到InitialContext。

InitialContext ctx = new InitialContext(); // no need to add anything to the context 

// A few reminders about the below: 
// 1. For multiple hosts, separate with commas, i.e. "corbaname::@<server:port>,:@<server2:port2>" 
// 2. If periods are used in the lookup name, they must be escaped, i.e. MyEJBHome-1.0 needs to be MyEJBHome-1\.0 
Object obj= ctx.lookup("corbaname::@example.test.com:11000/NameServiceServerRoot#cell/clusters/MyEJBHome12Cluster/MyEJBHome"); 

// Normal EJB things below 
MyEJBHome home = (MyEJBHome) javax.rmi.PortableRemoteObject.narrow(obj, MyEJBHome.class); 
MyEJB myEJB = home.create(); 
+0

謝謝尼克。有用! – Stony