In order to connect explicitly to the other JBoss system, you must include in the properties for your initial context, the URL for the remote server.
Properties jndiProps = new Properties();
InitialContext jndiContext = new InitialContext(jndiProps);
For a JBoss to JBoss call, you probably do not need to set up the JNDI packages and JNDI Factory, but you may want to do that for completeness. You must set up as though you are calling the other JBoss server as a remote client.
Otherwise, you will need to place all the EJBs in the one JBoss server.
Thanks for you help first!
I have setting as follow:
Hashtable env = new Hashtable();
InitialContext ctx = new InitialContext(env);
Object objref = ctx.lookup(JNDIString);
You say "You must set up as though you are calling the other JBoss server as a remote client."
How can I set up as though the calling the other JBoss server as a remote client?
Could you give me an example or part of code to doing that?
I'm also trying to make calls between EJBs in two instances of JBoss and am also encountering some difficulities. Any help you could give on this would be greatly appreciated.
I thought it was possible to reference BeanB, deployed on the second server, through entries in ejb-jar.xml and jboss.xml for BeanA, deployed on the first.
<..... remaining entries for BeanA ..../>
And that by doing so it would use the JNDI service of the first server without explicitly having to initialise a new InitialContext with the jndi properties of the remote server.
I haven't got this working yet but am I right in principle?
In theory it should work. I've seen this configured a few times in this manner. As the test, I would suggest first checking by trying a context lookup directly with the jndi-name as a string in code.
If that works, try using the ejb-ref-name indirection.