EJB Deploy, Lookup Problem
tvanbuskirk Apr 6, 2006 2:13 AMHi everyone, if you could help me with this I would be forever grateful! I've exhausted searching on the internet, and I've been through the trailblazer 3 times (but it focuses on accessing a local bean, rather than remote)
I'm getting a NameNotFoundException that has nothing to do w/ it not being bound. Looking in the JNDI, the name exists, and, according to the trailblazer, I'm accessing it correctly.
I downloaded JBoss AS 4.0.4.CR2 and installed the EJB 3.0 w/ Clustering.
The strangest part is that the error occurs no matter what name you put into the ctx.lookup() method. So, if it doesn't matter if I pass "HelloWorldBean/remote" or "JBossRocks" as a parameter to lookup(), I still get
javax.naming.NameNotFoundException: HelloWorldBean/remote.
I would really appreciate any help I can get ... thanks!! The details are below:
Here's the error:
javax.naming.NameNotFoundException: HelloWorldBean/remote at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:237) at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:150) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.ha.framework.server.HARMIServerImpl.invoke(HARMIServerImpl.java:209) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294) at sun.rmi.transport.Transport$1.run(Transport.java:153) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:149) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) at java.lang.Thread.run(Thread.java:613) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126) at org.jboss.ha.framework.server.HARMIServerImpl_Stub.invoke(Unknown Source) at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:172) at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:267) at $Proxy0.lookup(Unknown Source) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) at javax.naming.InitialContext.lookup(InitialContext.java:351) at HelloWorldJBossClient.connectToJBoss(HelloWorldJBossClient.java:134) at HelloWorldJBossClient.main(HelloWorldJBossClient.java:114)
Here's my remote interface:
public interface HelloWorld { public String getHelloWorldString(String reverseThis); }
Here's my stateless bean:
import javax.ejb.Remote; import javax.ejb.Stateless; import org.jboss.annotation.ejb.RemoteBinding; @Stateless @Remote ({HelloWorld.class}) @RemoteBinding (jndiBinding="HelloWorld") public class HelloWorldBean implements HelloWorld { public String getHelloWorldString(String reverseThis) { return reverseThis + "Back"; } }
This is JBoss showing the bean being deployed:
23:24:44,845 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=MentorBaseballBeans.jar,name=HelloWorldBean,service=EJB3 with dependencies: 23:24:45,374 INFO [EJBContainer] STARTED EJB: com.contendi.helloworld.beans.HelloWorldBean ejbName: HelloWorldBean 23:24:45,514 INFO [EJB3Deployer] Deployed: file:/Applications/jboss-4.0.4.CR2/server/default/deploy/MentorBaseballBeans.jar 23:24:45,599 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/ 23:24:45,986 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-10.0.1.6-8080
Here is my client code:
try { InitialContext ctx = new InitialContext(); ctx.addToEnvironment("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); ctx.addToEnvironment("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); ctx.addToEnvironment("java.naming.provider.url","10.0.1.6:8080"); HelloWorld hwRemote = (HelloWorld) ctx.lookup("HelloWorldBean/remote"); System.out.println(hwRemote.getHelloWorldString("TestThisString")); System.out.println(hwRemote.getHelloWorldString("TestAnotherString")); } catch (NamingException ex) { System.out.println(ex.toString()); }