-
1. Re: Invoking methods from an EJB on another machien
adrian.brock Jan 22, 2003 7:37 AM (in response to joycestack)You have the wrong jndi name
Regards,
Adrian -
2. Re: Invoking methods from an EJB on another machien
joycestack Jan 22, 2003 9:40 AM (in response to joycestack)Adrian,
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
<jndi-name>
jnp://banshee:1099/EncTests/ejbs/RemoteENCBean
</jndi-name>
Is it enough to have the ("java.naming.provider.url","jnp://172.16.220.160:1099");
in my client class.?
Thanks again,
Joyce -
3. Re: Invoking methods from an EJB on another machien
adrian.brock Jan 22, 2003 7:23 PM (in response to joycestack)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
ejb-jar.xml
<ejb-name>SomeEjb</ejb-name>
...
jboss.xml
<ejb-name>SomeEjb</ejb-name>
<jndi-name>ejbs/SomeEjb</jndi-name>
</session
Is usually enough.
Use lookup("ejbs/SomeEjb")
If you don't specify jndi-name in jboss.xml
it defaults to ejb-name
Regards,
Adrian -
4. Re: Invoking methods from an EJB on another machien
joycestack Jan 23, 2003 5:10 AM (in response to joycestack)Warjort,
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();
prop.put ("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
prop.put ("java.naming.provider.url","jnp://172.16.220.160:1099");
prop.put ("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
try
{
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");
System.out.println(str);
helloWorld.remove();
}
catch(Exception e)
{
e.printStackTrace();
}
Thanks alot,
Joyce -
5. Re: Invoking methods from an EJB on another machien
adrian.brock Jan 23, 2003 7:48 AM (in response to joycestack)Yes, you specify the ip address
in the initial context on the client.
Regards,
Adrian -
6. Re: Invoking methods from an EJB on another machien
joycestack Jan 23, 2003 9:40 AM (in response to joycestack)Thank You Adrian.
I'll get back to you. A bit sleepy after lunch so takes a little longer to do things.
Joyce -
7. Re: Invoking methods from an EJB on another machien
joycestack Jan 23, 2003 11:31 AM (in response to joycestack)Adrian,
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 ?
Joyce -
8. Re: Invoking methods from an EJB on another machien
adrian.brock Jan 23, 2003 9:08 PM (in response to joycestack)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?
Regards,
Adrian -
9. Re: Invoking methods from an EJB on another machien
joycestack Jan 27, 2003 6:01 AM (in response to joycestack)Hello Adrian,
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.
Thanks,
Joyce -
10. Re: Invoking methods from an EJB on another machien
adrian.brock Jan 27, 2003 6:12 AM (in response to joycestack)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.
Regards,
Adrian -
11. Re: Invoking methods from an EJB on another machien
joycestack Jan 27, 2003 6:56 AM (in response to joycestack)Adrian,
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.
Thanks,
Joyce -
12. Re: Invoking methods from an EJB on another machien
joycestack Jan 27, 2003 7:05 AM (in response to joycestack)Adrian,
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
@echo on
set LCP=.
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?
Joyce -
13. Re: Invoking methods from an EJB on another machien
joycestack Jan 27, 2003 7:14 AM (in response to joycestack)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.
Thanks -
14. Re: Invoking methods from an EJB on another machien
adrian.brock Jan 27, 2003 1:54 PM (in response to joycestack)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.
Regards,
Adrian