4 Replies Latest reply on Dec 11, 2013 3:50 AM by velraman

    Problem in invoking a Remote EJB in JBoss.5.1.0 GA Server from my local desktop ejb in same jboss version

    velraman

      Hi JBoss experts,

      We need a to do a POC on calling remote EJB from my local ejb, both jboss servers running on same version Jboss.5.1.0 GA.

      We are getting so many problems in implementing this.

      I have the following jars included in jboss5.1.0 GA of my client.

       

      jboss-ejb-client-2.0.0.Beta3.jar

      jboss-logging-3.1.0.CR2.jar

      jboss-remote-naming-1.0.6.Final.jar

      jboss-remoting-3.2.16.GA.jar

      xnio-api-3.1.0.CR5

      xnio-nio-3.0.0.GA

       

      I have the code of getting the context as well.

       

                   Properties env = new Properties();
                   env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                   env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                   env.put(Context.PROVIDER_URL, "jnp://10.86.24.7:1099");
                   InitialContext context = new InitialContext(env);            System.out.println("context initialized successfully.");

       

       

      But I'm getting below error in logs :

       

      2013-11-12 20:57:22,430 INFO  [org.xnio] (http-0.0.0.0-8089-2) XNIO Version 3.1.0.CR5

      2013-11-12 20:57:22,450 INFO  [org.xnio.nio] (http-0.0.0.0-8089-2) XNIO NIO Implementation Version 3.1.0.CR5

      2013-11-12 20:57:22,490 INFO  [STDOUT] (http-0.0.0.0-8089-2) The exception is Failed to create remoting connection

      2013-11-12 20:57:22,490 ERROR [STDERR] (http-0.0.0.0-8089-2) javax.naming.NamingException: Failed to create remoting connection [Root exception is java.util.ServiceConfigurationError: org.xnio.XnioProvider: Provider org.xnio.nio.NioXnioProvider could not be instantiated: java.lang.NoSuchMethodError: org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V]

      2013-11-12 20:57:22,490 ERROR [STDERR] (http-0.0.0.0-8089-2)     at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:51)

      2013-11-12 20:57:22,490 ERROR [STDERR] (http-0.0.0.0-8089-2)     at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:152)

      2013-11-12 20:57:22,490 ERROR [STDERR] (http-0.0.0.0-8089-2)     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)

      2013-11-12 20:57:22,490 ERROR [STDERR] (http-0.0.0.0-8089-2)     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

       

      Do you have any documentation of how to connect and invoke remote EJB specifically for Jboss5.1.0. GA (NOT for JBoss AS7 or 6)??

       

      Please advice me whether remote EJB call works in Jboss.5.1.0.GA because of the issue ??

       

      Thanks

      Velmurugan R

        • 1. Re: Problem in invoking a Remote EJB in JBoss.5.1.0 GA Server from my local desktop ejb in same jboss version
          wdfink

          Hello Velmurugan,

          welcome to the forums.

           

          Do you say that both sides are JBoss5.1, right?

          Why you add such libraries? As far as I see you use WildFly libraries which will definitive not work in that environment.

          Drop all this additional libs and it should work.

          • 2. Re: Problem in invoking a Remote EJB in JBoss.5.1.0 GA Server from my local desktop ejb in same jboss version
            velraman

            Hi Jboss expert Wolf-Dieter Fink,

            1. Yes both sides are JBoss5.1

            2. I added such libraries, because initially Jboss thrown ClassNotFoundException for org.jboss.naming.remote.client.InitialContextFactory class and org.xnio.Options class and other few classes, so I added the above jars, The jars I mentioned above are downloaded from grepcode and jboss sites. I dont see why such jars from WildFly libraries will affect this environement since doesn't show any conflicts so far.

            3. I have all the required jars I believe, but the jboss-logging-3.1.0.CR2.jar which has class org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V] method, this Logger class is not considered in jboss classpath, but instead the org.jboss.logging.Logger class is taken from jboss-logging-spi.jar. which doesnt have required method org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V].

             

             

            How to troubleshoot the issue like overriding the jboss default org.jboss.logging.Logger class in jboss-logging-spi.jar by the same class in jar jboss-logging-3.1.0.CR2.jar???

             

             

            The right code I'm posting now to get the context.

             

                Properties env = new Properties();
                 env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
                 env.put(Context.PROVIDER_URL, "jnp://10.86.24.7:1099");
                 InitialContext context = new InitialContext(env);   System.out.println("context initialized successfully."); 
                 return context;

             

             

             

             

            Thanks

            Velmurugan R

            1 of 1 people found this helpful
            • 3. Re: Problem in invoking a Remote EJB in JBoss.5.1.0 GA Server from my local desktop ejb in same jboss version
              wdfink

              Sorry,

              I get confused also.

              For JBoss5 you should use this properties:

              env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.NamingContextFactory");
              env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
              env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");

               

              The CONTEXT_FACTORY you use it indeed of AS7, but there is no 'jnp' protocol and the connect is different.

              • 4. Re: Problem in invoking a Remote EJB in JBoss.5.1.0 GA Server from my local desktop ejb in same jboss version
                velraman

                Hi Jboss expert Wolf-Dieter Fink,

                It works fine as you suggested the above code, which I'm pasting here below once again.


                   env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.NamingContextFactory");

                    env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");

                    env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");

                 

                <note>It works good </note>

                 

                 

                However I have a question, whats is the difference between these two below context factory

                1. org.jboss.naming.NamingContextFactory

                2. org.jboss.naming.remote.client.InitialContextFactory.

                 

                and both the context factory library present in both the jboss 5 version.