ejb und jndi
turgar
- java
0 turgar
Hallo,
ich habe mich an einer einfachen ejb versucht, habe aber Probleme mit jndi.
Meine Bean-Client sieht folgendermaßen aus:
import java.beans.Beans;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import beans.Calculator;
public class Start
{
public static void main(String[] args)
{
try
{
Properties props = new Properties();
props.load(new FileInputStream("jndi.properties"));
InitialContext ctx = new InitialContext(props);
beans.Calculator calc = (Calculator) ctx.lookup("CalculatorBean/remote");
System.out.println("1+1" + calc.sum(1,1));
}
catch(FileNotFoundException fnfe)
{
System.out.println("Datei wurde nicht gefunden: " + fnfe.getMessage() + " ");
fnfe.printStackTrace();
}
catch(IOException ioe)
{
System.out.println("Fehler beim Lesen der Config: " + ioe.getMessage() + " ");
ioe.printStackTrace();
}
catch(NamingException ne)
{
System.out.println("Namensaufloesungsfehler: " + ne.getMessage() + " ");
ne.printStackTrace();
}
}
}
Die Exception die ich erhalte sieht folgendermaßen aus:
Namensaufloesungsfehler: remote not bound javax.naming.NameNotFoundException: remote not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
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:597)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Start.main(Start.java:22)
Kann mir jemand weiterhelfen?
Was ich noch vergessen habe:
Laut log-File vom Server startet das Bean korrekt: "2008-06-05 14:44:39,568 INFO [org.jboss.ejb3.EJBContainer] STARTED EJB: beans.CalculatorBean ejbName: CalculatorBean"