lookup-problem in a swing-client
oliverroell Jun 29, 2005 10:20 AMHello,
I am using JBoss 4.0.2, JDK 1.5.0_03 & Eclipse 3.02 and I have successfully deployed the "Fibonaci Computation"-application from the JBoss-Eclipse-Tutorial.
Now I want to connect to the Fibo-EJB from a swing-client with the following program:
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import tutorial.interfaces.FiboHome;
public class SwingClient {
public static void main(String[] args) {
try {
Hashtable props = new Hashtable();
props.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.provider.url",
"jnp://localhost:1099");
props.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
Context context = new InitialContext(props);
Object ref = context.lookup("java:/comp/env/ejb/Fibo");
} catch (Exception ex) {
System.err.println("Caught an exception:");
ex.printStackTrace();
}
}
}
After running this program, an exception is occurred:
Caught an exception:
javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
at org.jnp.server.NamingServer.lookup(NamingServer.java:249)
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:595)
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.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at client.SwingClient.main(SwingClient.java:39)
This line doesn't work:
Object ref = context.lookup("java:/comp/env/ejb/Fibo");
But what's wrong with my code?