You have the wrong jndi name
Again you come to my rescue. Can you tell me do I need to have ejb-ref's in my jboss.xml. ?
I have an example here (the JBoss 3 Docs) and it goes on that the jndi name for remote calls (i think i have the correct context) is something like
Is it enough to have the ("java.naming.provider.url","jnp://172.16.220.160:1099");
in my client class.?
The format you quote is for an ejb
accessing another ejb on a different machine.
You want to avoid jnp/rmi invocations where possible
because they involve serialization.
For a simple ejb
Is usually enough.
If you don't specify jndi-name in jboss.xml
it defaults to ejb-name
Thanks a million for the reply. All my code that allowed me to run HelloWorld on my machine should technically not need to change is that correct ?
Do I still need to specify the IP of the machine I need to connect to in my client code like below
Hashtable prop = new Hashtable();
Context ctx = new InitialContext(prop);
Object obj = ctx.lookup("helloworld/HelloWorld");
HelloWorldHome home = (HelloWorldHome)javax.rmi.PortableRemoteObject.narrow(obj, HelloWorldHome.class);
HelloWorld helloWorld = home.create();
String str = helloWorld.sayHelloEJB("JOYCE is COOL");
Yes, you specify the ip address
in the initial context on the client.
Thank You Adrian.
I'll get back to you. A bit sleepy after lunch so takes a little longer to do things.
Can I ask your help again please? I have my Client jar in my client folder on my windows machine. I have my deployment jar file in the deploy folder on the linux machine. I still get the NullPointerException.
Any ideas on how i can debug this ?
You can try enumerating the initial context
to see what is available.
Also do you have the redhat problem
where etc/hosts points localhost at your ip address?
Sorry for the delay in getting back to you. I dont know much about unix but my etc/hosts file I thought was only used to map computer names to IP addresses. If I am using the IP address surely I dont need to edit this file.
RMI will pick the first ip address for your hostname,
and pass that with the remote stub.
If the first one in /etc/hosts is 127.0.0.1 it won't
work. Redhat configure it like this to improve the
performance of some unix programs that don't check whether
they are local.
I have removed everything from my /etc/hosts file except the router IP address. Can I just write down the steps I have done.
1. Build the helloworld example on the linux machine and executed this with a script. All the appropiate files are in place.
2. Copied the Client.jar file onto my PC. The client class is set to look at the linux machine using the IP address.
3. I execute the CLient.jar with a bat file on the PC and get a NullPointerException.
I am so stupid. The runclient.bat file uses the jar files from the jboss installed on my machine.
This is what it looks like
REM Default locations of jars we depend on
for %%i in (E:\jboss-3.0.4_tomcat-4.1.12\client\*.jar) do call lcp.bat %%i
for %%i in (..\..\lib\*.jar) do call lcp.bat %%i
for %%i in (..\client\*.jar) do call lcp.bat %%i
REM This automatically adds system classes to CLASSPATH
if exist C:\jdk1.3.1\jre\lib\tools.jar set LCP=%LCP%;C:\jdk1.3.1\jre\lib\tools.jar
echo C:\jdk1.3.1\jre\bin\java.exe -classpath "%LCP%" helloworld.client.HelloClient
C:\jdk1.3.1\jre\bin\java.exe -classpath "%LCP%" helloworld.client.HelloClient
Need to have this point at my linux machine right.? Whats the easiest way to execute my client on the linux from my PC.? Am I doing things backwards?
Even if I run on my pc the following
java -classpath .;j2ee.jar;HelloClient.jar HelloClient
I get a NoClassDefFoundException.
How do I execute the HelloClient.jar file on my PC to find the DD etc on the remote linux machine.
Sorry Adrian for this but I need to be able to have this much done for work. A colleague of mine is back tomorrow after a Sun EJB course and I should be alot wiser after her training. But until then Im afraid I am relying on you.
You want jboss-j2ee.jar
You also need jnp-client.jar
Have you got the quickstart guide?
If I remember correctly, there is a whole chapter on
making a connection from a client.