2 Replies Latest reply on Feb 8, 2003 12:03 AM by Sanjay

    Exception while calling EJBs deployed on remote machine

    Sanjay Newbie

      Thanks a lot. I solved the problem of RMISecurityManager by putting all EJB jar files in clients classpath. Now client is in position to lookup beans deployed on another instance of jboss on the same machine and it works fine. But for looking up beans deployed on jboss on another machine takes too much time and yields no result. neither it gives any exception nor does it send any request to specified machine. Why is it so ????. client only keeps processing.
      Moreover I don't want to add following snippet in every servlet that calls EJB deployed on remote machine. Hence let me know in which file should I make this configurations and how to call that file while deployment so that each client can lookup for the bean on remote machine.

      Properties env = new Properties();
      env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.setProperty(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
      env.setProperty(Context.PROVIDER_URL, "xxx.xxx.xxx.xxx:1099");

      Awaiting your reply

      Thanks & Regards,
      Sanjay

        • 1. Re: Exception while calling EJBs deployed on remote machine
          Beppe Newbie

          I am a beginner and I have a problem after the lookup, when I had to do narrow.
          My client is:

          import javax.naming.Context;
          import javax.naming.InitialContext;
          import java.util.Hashtable;

          public class ProvaClient{
          public static void main(String [] args){

          java.util.Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY,
          "org.jnp.interfaces.NamingContextFactory");
          env.put(Context.PROVIDER_URL, "localhost:1099");
          env.put("java.naming.factory.url.pkgs",
          "org.jboss.naming:org.jnp.interfaces");

          try
          {
          Context ctx = new InitialContext(env);
          Object obj = ctx.lookup( "Prova/ProvaEJB" );
          ProvaHome home =(ProvaHome)javax.rmi.PortableRemoteObject.narrow(obj, ProvaHome.class);
          Prova prova = home.create();
          System.out.println( prova.ProvaMetodo());
          prova.remove();
          }
          catch ( Exception e )
          {
          e.printStackTrace();
          System.out.println( "Exception: " + e.getMessage() );
          }
          }
          }

          and in the same directory there is Prova.class and ProvaHome.class.
          The error when I execute the Client is:

          java.lang.ClassCastException
          Exception: null
          Process terminated with exit code 0
          at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
          at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
          at ProvaClient.main(ProvaClient.java:19)

          The ejb is on the server, I have it in the Service, and the lookup is right, but the obj returned is null probably, why????

          The directory with the Client isn't under the server directory.

          Thanks for reply.

          • 2. Re: Exception while calling EJBs deployed on remote machine
            Sanjay Newbie

            Hello,
            That exception is due to existance of a single class in multiple jar files. Hence make sure that there is only one copy of the classes you are using.

            Moreover make sure that you have not set : java.naming.provider.url=localhost:1099 option in jndi.properties file or somewhere else in your code this leads to rmi call and gives the same problem for PortableRemoteObject. Hope this helps you.

            Regds,
            Sanjay