3 Replies Latest reply on Sep 26, 2004 9:04 PM by rimmeraj

    Problem using remote interface

    jgbargar

      Hello there,

      Our application (in a bold new use of J2EE technology ;)) has Session EJBs that are called remotely. I am having a problem where I am able to successfully lookup the Home but then the create() method is failing. I have confirmed that the Session bean in question is deploying successfully by watching the console at deploy time as well as looking at the jmx-console. Additionally, the lookup listen port is correct as confirmed by a telnet. Any insight on this would be greatly appreciated as I am stuck on something that I feel should be routine, and am unable to move forward on the project I am working on.

      ------------------------
      calling code:
      ------------------------

      public void testLookup() throws Throwable {

      String method = "testLookup";
      assertTrue(getHome() != null);

      WebManagerRemote wmr = getHome().create();

      log(getHome().toString());
      }

      ------------------------
      helper method code:
      ------------------------

      WebManagerRemoteHome getHome() throws Throwable {

      Hashtable env = new Hashtable();

      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, "127.0.0.1:1099");

      String jndiName = "com.pixelfixx.service.WebManager";

      // Obtain initial context
      javax.naming.InitialContext initialContext = new javax.naming.InitialContext(env);
      Class narrowTo = com.pixelfixx.service.WebManagerRemoteHome.class;

      Object objRef;

      try {
      objRef = initialContext.lookup(jndiName);
      // only narrow if necessary
      if (narrowTo.isInstance(java.rmi.Remote.class))
      objRef = javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
      } finally {
      initialContext.close();
      }

      return (com.pixelfixx.service.WebManagerRemoteHome) objRef;
      }

      ------------------------
      error
      ------------------------

      [junit] java.lang.IndexOutOfBoundsException: Index: 14, Size: 14
      [junit] at java.util.ArrayList.RangeCheck(ArrayList.java:507)
      [junit] at java.util.ArrayList.get(ArrayList.java:324)
      [junit] at org.jboss.invocation.InvocationKey.readResolve(InvocationKey.java:118)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [junit] at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:925)
      [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1655)
      [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      [junit] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      [junit] at java.util.HashMap.readObject(HashMap.java:1005)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [junit] at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
      [junit] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
      [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
      [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      [junit] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
      [junit] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
      [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
      [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      [junit] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      [junit] at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:109)
      [junit] at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
      [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
      [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      [junit] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
      [junit] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
      [junit] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
      [junit] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      [junit] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      [junit] at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      [junit] at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:139)
      [junit] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:92)
      [junit] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
      [junit] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
      [junit] at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:175)
      [junit] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:82)
      [junit] at $Proxy0.create(Unknown Source)
      [junit] at com.pixelfixx.service.WebManagerTest.testLookup(WebManagerTest.java:113)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [junit]
      [junit] Testcase: testLookup

        • 1. Re: Problem using remote interface

          Having been through this recently , you did not give us the proper info. What invokers are you using and what are your values in the inital context. Without this info I am flying blind but I am going to go out on a limb and say that jboss thinks you are local, ie your machine name resolves to localhost. If you telnet to 1099 at the very end of the string you get back you will see what your JBOSS server thinks it's IP address is.

          • 2. Re: Problem using remote interface
            jgbargar

            First, let me clarify that the client is on the same machine - just not in the container (they're junit tests). It is this attempt to get the remote interface that is proving problematic. Using local interfaces from a web app deployed in JBoss as well as inter-EJB calls are working fine. Both remote and local interfaces are deploying without error in JBoss and they are appearing fine in the jmx console JNDI listing:

            +- com.pixelfixx.service.WebManager (proxy: $Proxy60 implements interface com.pixelfixx.service.WebManagerRemoteHome,interface javax.ejb.Handle)
            +- local (class: org.jnp.interfaces.NamingContext)
            | +- com.pixelfixx.service.WebManager (proxy: $Proxy40 implements interface com.pixelfixx.service.WebManagerLocalHome)

            The only invokers I can see deployed are http and jmx, which as far as I know aren't a factor here. Please let me know what I should look for if I am wrong on this.

            RE: initial context values, what information would be useful beyond the environment info that I've already included in the code posting? With the initial context I can list the bindings, but (again AFAIK) that is pretty much what I've listed above from the JNDI listing in jmx console.

            One final comment about the theory that JBoss thinks the caller is local. If I am specifically looking up the remote interface by jndi name, why would JBoss still return the local interface?

            Feedback is much appreciated,

            Jeremy

            • 3. Re: Problem using remote interface

              Ah.. The old with a hammer in my hand the world is a nail. Looks like it is having problems serializing the object on the client. What does the interface you are returning look like and is the one in your client classpath the same as the server?