1 Reply Latest reply on Apr 26, 2007 7:58 AM by smeier

    Problems calling methods in session beans on second JBoss in

    dr-dive

      Hi,
      I have installed two JBoss instances on the same computer, and they both run fine. Now I tried to access a session bean on JBoss 2 from a session bean deployed in JBoss 1. For this purpose I use the following code:

      Properties jndiProps = new Properties();
      jndiProps.put(Context.PROVIDER_URL, "jnp://xxx.xxx.xxx.xxx:11099");
      jndiProps.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
      jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      Context ejbContext = new InitialContext(jndiProps);
      RemoteBeanHome remoteBeanHome = (RemoteBeanHome)ejbContext.lookup(jndiNameOfRemoteBean);
      


      The result is that the bean I tried to call in JBoss 2 is called within JBoss 1 (The bean is deployed on both JBoss instances).

      Any ideas why this is happening?

      By the way, I 'm using JBoss 3.2.7 and the files ejb-jar.xml and jboss.xml are the same on both servers. Is that the problem?

      Thanks in advance,
      Thorsten.



        • 1. Re: Problems calling methods in session beans on second JBos

          Hi dr-dive,

          I've tried it out and ran into the same problem. The reason for the problem might be, that I have a jndi.properties in my classpath, with the line

          java.naming.provider.url=localhost
          


          in it. The API doc for javax.naming.InitialContext http://java.sun.com/j2se/1.4.2/docs/api/javax/naming/InitialContext.html says that the contents of a jndi.properties are somehow merged together with the properties explicitly provided to the constructor.
          I solved the problem by removing the home- and remote-interfaces declaration from the ejb-jar.xml on the server that is supposed to perform the remote call. Perhaps there's a better solution but at least that worked for me.

          Best regards,
          Stefan