-
1. Re: Two Server connection problem
jonlee Sep 23, 2003 10:05 PM (in response to vincentchun)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.
e.g.
Properties jndiProps = new Properties();
jndiProps.setProperty("java.naming.provider.url", "jnp://localhost:1099");
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. -
2. Re: Two Server connection problem
vincentchun Sep 23, 2003 11:32 PM (in response to vincentchun)Thanks for you help first!
I have setting as follow:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, ServerBUrl);
env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
try {
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? -
3. Re: Two Server connection problem
sophiew Oct 7, 2003 2:02 AM (in response to vincentchun)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.
<ejb-name>BeanA</ejb-name>
<..... remaining entries for BeanA ..../>
<ejb-ref>
<ejb-ref-name>BeanB</ejb-ref-name>
<jndi-name>jnp://otherhost:1099/application/ejb/BeanB</jndi-name>
</ejb-ref>
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? -
4. Re: Two Server connection problem
jonlee Oct 7, 2003 8:12 AM (in response to vincentchun)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.
e.g. ctx.lookup("jnp://otherhost:1099/application/ejb/BeanB");
If that works, try using the ejb-ref-name indirection.