Using Remote Enterprise Beans
843833Apr 28 2004 — edited May 6 2004Dear Forum users,
I have the following problem: I created a stateless session bean, packaged it together with a webapplication and a client application into one application and deployed it to the enterprise server. Everything works fine but one thing. The client application only works if it is executed on the same system as the application server. If I deploy my application at a remote server the client application still looks on the local system (even if I create a new client jar file from the deployment tool) for the enterprise bean which is at the remote server.
I use appclient to execute the client application. I already tried lots of suggestions but none have worked so far. The important part of the code for the client is as follows:
-----
Context initial = new InitialContext();
java.lang.Object objref = initial.lookup("comp:env/ejb/LoanEJB");
// Get a handle to the home interface
LoanHome home = (LoanHome)PortableRemoteObject.narrow(objref, LoanHome.class);
// Instantiate the Loan EJB
Loan loanEJB = home.create();
-----
As said, this works fine local, but not remote. I tried to:
- set properties: This is not allowed and generated a security exception (using appclient)
- use:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://myserver.nl:3700");
Context initial = new InitialContext(env);
- use:
java.lang.Object objref = initial.lookup("LoanBean");
LoanBean is the JNDI name of the enterprise bean.
but all these things did not work
What am I missing? How do I get when executing appclient -client LoanApplicationClient.jar to make a connection to the remote server. Do I need to change settings on the application server as well?
By the way, it is not a server or network problem, the server is running and accepts connections on all ports from my local machine.
Thank you very much for your help,
Benedikt Kratz
I am willing to provide more information if requested.