5 Replies Latest reply on Sep 24, 2001 2:27 PM by spatemp

    I am having trouble testing EJB across network.

    spatemp Newbie

      I am trying to test an ejb client that would call a method on say "theserver.domain.com" machine. I get the following erros when I run the client program.
      The EJB and client works fine when jboss and client is on one machine. Thanks for you help.

      [java] Got context
      [java] javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb.plugins.jrmp.interfaces.EJBMetaDataImpl; Local class not compatible: stream classdesc serialVersionUID=3328424568966982431 local class serialVersionUID=2590026239352080415]

      public static void main(String[] args)
      // Enclosing the whole process in a single `try' block is not an ideal way
      // to do exception handling, but I don't want to clutter the program up
      // with catch blocks
      Properties env = new Properties();

      env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.setProperty("java.naming.provider.url", "theserver.domain.com:1099");
      env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

      // cachedCTX = new InitialContext(env);

      // Get a naming context
      InitialContext jndiContext = new InitialContext(env);
      System.out.println("Got context");

      // Get a reference to the Interest Bean
      Object ref = jndiContext.lookup("interest/Interest");
      System.out.println("Got reference");

      // Get a reference from this to the Bean's Home interface
      InterestHome home = (InterestHome)
      PortableRemoteObject.narrow(ref, InterestHome.class);

      // Create an Interest object from the Home interface
      Interest interest = home.create();

      // call the calculateCompoundInterest() method to do the calculation
      System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
      System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
      catch(Exception e)

        • 1. Re: I am having trouble testing EJB across network.
          ashutosh s Newbie

          The java.io.InvalidClassException is generally raised when the Serialization runtime detects a problem with a Class.
          Possibly, the class at the client side does not match the serial version of the class in the stream.
          You may be having two diferent versions of the either the Home or the Remote Interface on the client and the server. These classes would be required while casting the Object that u receive from either the lookup() or the create().


          • 2. Re: I am having trouble testing EJB across network.
            spatemp Newbie

            The InteresetBean has not been changed at all. It comes from the documentation-example.zip from jboss (http://www.jboss.org/doco_files/). I modified the InterestClient as seen above but not the InterestBean. So, as you can see the "Got Context" message is printed and I think it blows up on the getting reference. So what do I have to change in this client code to have the "interest.calculateCompoundInterest(1000, 0.10, 2)" method called for Interest EJB running on different machine then the client. Can some one be more specific. Thanks.

            • 3. Re: I am having trouble testing EJB across network.
              Kenney Westerhof Newbie

              Your code is OK, but you may want to change your
              property to "org.jboss.naming:org.jnp.interfaces".

              • 4. Re: I am having trouble testing EJB across network.
                spatemp Newbie

                After changing the following, I am now getting this error message.

                env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                env.setProperty("java.naming.provider.url", "jnp://theserver.domain.com:1099");
                env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
                [java] Got context
                [java] javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host:; nested exception is:
                [java] java.net.ConnectException: Connection refused: connect]

                • 5. Re: I am having trouble testing EJB across network.
                  spatemp Newbie

                  I found out what the problem was. It turned out to be a firewall issue. I did have successful test with another machine. I just wanted to make sure the code was ok and thanks for every one's help.