2016-05-13 11 views
0

Ich versuche einen EJB-Aufruf von Jboss (6.4 EAP) nach WebSphere (7.x) zu erstellen. Ich habe ein funktionierendes Beispiel von WebSphere (WAS) zu WAS, aber derselbe Ort und Suchname geben eine Ausnahme für den Namen nicht gefunden zurück. Ich teste gerade diese Tests innerhalb einer Web-Anwendung, die als WAR in Jboss implementiert wurde.Jboss (6.4 EAP) zu WebSphere (7.x)

Ich habe die EJB nicht definiert in einer web.xml noch in einer jboss-web.xml (ich glaube nicht, dass ich es brauche). Die EJB-Version in WebSphere ist 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"); 

Die oben wirft einen 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) 

ich auch versucht, die Sonne Fabrik zu verwenden: com.sun.jndi.cosnaming.CNCtxFactory

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

, die etwas ähnliche Ergebnisse liefert :

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) 

Das obige wurde unter Verwendung der folgenden Site versucht: Reference Link First

Ich versuchte dann, die IBM-Client-Gläser zu verwenden, nur um zu sehen, ob ich einen Anruf zur Arbeit bekommen kann. Ich folgte diesem Ort: Reference Link 2

Ich habe 2 Gläser:

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

Ich fügte auch alle Gläser hinzu, die die EJB-Klassen und Stub-Klassen enthielten. Ich habe die Factory von com.ibm.websphere.naming.WsnInitialContextFactory verwendet. Es sieht die EJB feine, aber während der PortableRemoteObject.narrow Anruf, schlägt es mit einem

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

ich bezweifle ich die WAS Gläser zu verwenden, wäre in der Lage sowieso, wie ich mit Java 1.8 laufen haben, die gewonnen‘ Ich arbeite mit den oben genannten Client-Jars und bevorzuge auch die Verwendung von IBM-Jars in JBoss, wenn Jboss dies tun kann.

+0

Sie wahrscheinlich wissen, dass standardmäßig WebSphere iiop auf 2809 hört, nicht 11000. Wenn das nicht das Problem ist, vielleicht etwas auf dieser Seite wird hilfreich sein: https://www.ibm.com/support/ Knowledge Center/SSAW57_7.0.0/com.ibm.websphere.nd.doc/info/ae/ae/rnam_example_prop3.html –

+0

Korrigieren meines vorherigen Kommentars: Normalerweise suchen Sie den InitialContext über den Bootstrap-Port, der standardmäßig 2809, nicht 11000 ist Das ist nicht das Problem, vielleicht ist etwas auf dieser Seite hilfreich: https://www.ibm.com/support/knowledgecenter/SSAW57_7.0.0/com.ibm.websphere.nd.doc/info/ae/ae/ rnam_example_prop3.html Diese Seite kann auch hilfreich sein: https://www.ibm.com/support/knowledgecenter/was_beta/com.ibm.websphere.base.doc/ae/rnam_example_prop1.html –

+0

Ich begegne dem gleichen Problem. kannst du mir sagen, wie du es gelöst hast? – Stony

Antwort

1

Wir haben am Ende eine Lösung für dieses Problem gefunden. Es gibt eine magische Menge von Zeichen, die in der Suche nach JBoss sein müssen. Zuvor waren die Provider-URL und JNDI getrennt. Jetzt befinden sie sich alle in der Lookup-Zeichenfolge, wie unten gezeigt. Außerdem wurden dem InitialContext keine weiteren Parameter hinzugefügt.

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

Danke Nick. Es klappt! – Stony