Object obj = ctx.lookup("java:comp/env/ejb/helloJNDI"); "ejb/helloJNDI"为 JNDI。 你要用deploytool在EJB Refs中设置In the tree, select HelloClient. Select the EJB Refs tab. Click Add. In the Coded Name column, enter ejb/helloJNDI. In the Type column, select Session. In the Interfaces column, select Remote. In the Home Interface column, enter Hello. In the Local/Remote Interface column, enter Hello
javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
也只是我排版时的手误,应该是
javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);的希望再次得到在家的帮助,非常感谢!
你是否把你的client.jar加入包中;
再看看jndi是否和你lookup的相同(看你的程序应该是相同的,因为是在narrow出的错)。我是刚开始学ejb。不过hello已通过
"ejb/helloJNDI"为 JNDI。
你要用deploytool在EJB Refs中设置In the tree, select HelloClient.
Select the EJB Refs tab.
Click Add.
In the Coded Name column, enter ejb/helloJNDI.
In the Type column, select Session.
In the Interfaces column, select Remote.
In the Home Interface column, enter Hello.
In the Local/Remote Interface column, enter Hello
elloHome.class);我看是这句话有错!
elloHome.class);
该成:
javax.rmi.PortableRemoteObject.narrow(obj,
HelloHome.class);