3 Replies Latest reply on Jun 1, 2015 12:24 PM by andyfreeman

    Calling EJB running on JBoss 5.1 from app running on JBoss 6.3

    andyfreeman

      Hi all,

       

      I have an EJB that is deployed on a jboss 5.1 server which I then need to call remotely from an application running on jboss 6.3. Unfortunately I can't seem to figure out what settings I need to configure to make the connection.

       

      I have successfully called remote EJBs from jboss 6.3 to jboss 6.3 using the following settings, but these don't work  for 6.3 to 5.1:-

       

      java.naming.provider.url=remote://192.x.x.x:4447

      java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory

      jboss.naming.client.endpoint.name=JNDI-Endpoint

       

      I believe the port on 5.1 should be 1099 but on changing to this I got an exception about the message length being incorrect. Have dug around I have found various values suggested, for example:-

       

      java.naming.provider.url=jnp://192.x.x.x:1199

      java.naming.factory.initial=org.jboss.naming.NamingContextFactory

      jboss.naming.client.endpoint.name=JNDI-Endpoint

       

      But this gave me an exception:

      nested exception is javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.NamingContextFactory from classloader ModuleClassLoader for Module

       

      I'm not sure if it is just a case of having the right property file settings or whether I need to include some classes from jboss 5.1 on my jboss 6.3 classpath??

       

      Just for info as I'm not sure that it makes any difference but the application on 6.3 is using spring to do the lookup:-

          <jee:remote-slsb id="xxxEJBService"

                           jndi-name="xxxEJB/xxEJBEJB/remote-com.mypackage.xxxEJB.xxxEJB"

                           business-interface="com.mypackage.xxxEJB.xxxEJB"

                           environment-ref="ejbJndiProperties"

                           cache-home="false"

                           lookup-home-on-startup="false"

                           refresh-home-on-connect-failure="true" />

       

      Any help anyone could give would be much appreciated.

        • 1. Re: Calling EJB running on JBoss 5.1 from app running on JBoss 6.3
          lylewang

          I guess when you say "JBoss 6.3" you actually mean "JBoss EAP 6.3" ?

          EJB technology has been changed a lot between JBoss AS5/EAP5  and  JBoss AS7/EAP6.


          As you're calling an EJB deployed on EAP 5, you're going to use the client jars from JBoss EAP 5 "$JBOSS_HOME/client". Package these client jars (and dependencies) in your client application (which is deployed on EAP 6), or install them as a custom module in EAP 6. Then you will be looking at some code / setup as described in here: https://developer.jboss.org/wiki/howtouseanapplicationclientinjboss-5


          Sorry to say that but to be honest this is not something I would encourage you to do, as this approach is not really officially supported, and you might end up with some unknown issues or not working very well sometimes.


          Another option is to use Webservices (JAX-WS/JAX-RPC/JAX-RS), or upgrade your EAP 5 to 6.x

          • 2. Re: Calling EJB running on JBoss 5.1 from app running on JBoss 6.3
            ehugonnet

            The naming service has changed between EAP 6.3 and EAP5. In EAP5, it is using JNP, thus you will have to create your own JNDI context to be able to call the remote EJB using some properties file or setting the env 'by hand' with something like :

            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

            java.naming.provider.url=jnp://127.0.0.1:1099

            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

            java.naming.security.principal=admin

            java.naming.security.credentials=passw0rd!

            • 3. Re: Calling EJB running on JBoss 5.1 from app running on JBoss 6.3
              andyfreeman

              Thanks for that Lyle, not the answer I wanted but the one I did expect. I had already tried to add a module for the client jars, but as you thought might happen I ended up getting some strange errors and so gave up on this approach. Looks like I'll have to push for an upgrade so they are both using the same version of JBoss.