Why can't I invoke a ejb in Tomcat?
843836Aug 30 2003 — edited Aug 30 2003Hi everyone:
I invoke a ejb in Tomcat(the ejb is in the weblogic in the same computer with tomcat).The jsp code is:
/////////////////first method//////////////////////
Context ctx=new InitialContext();
Object obj=ctx.lookup("ejb/Hello");
Hellohome home=(Hellohome)PortableRemoteObject.narrow(obj,Hellohome.class);
Hello hello=home.create();
out.println(hello.getHello());
///////////////second method//////////////////
Hashtable ht=new Hashtable();
Context ctx=null;
ht.put(ctx.PROVIDER_URL, "t3://127.0.0.1:7001" ); // t3://127.0.0.1:7001
ht.put(ctx.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ctx = new InitialContext();
Hellohome home= (Hellohome) javax.rmi.PortableRemoteObject.narrow (ctx.lookup ("HelloEJB"),Hellohome.class);
Hello hello=home.create();
out.println(hello.getHello());
Is there any different?If I want to invoke the EJB which is in the weblogic.The Tomcat says:
//////////////////////////////////////////////
Name HelloEJB is not bound in this Context
But I bound it in the weblogic and I add the "
<ejb-ref>
<ejb-ref-name>HelloEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>lyoejb.Hellohome</home>
<remote>lyoejb.Hello</remote>
<ejb-link>Hello.jar#HelloEJB</ejb-link>
</ejb-ref>"
in the ejb-jar.xml. And I copy the j2ee.jar,wlclient.jar,Hello.jar to Tomcat/....web-inf/lib
How to setting the web.xml in the Tomcat?