3 Replies Latest reply on Sep 26, 2003 1:52 AM by Dmitri Zamyslov

    JBoss -> RMI

    Dmitri Zamyslov Newbie

      Hi !

      I don't know if I've got in the right Forum, but here is my problem:

      I have standalone RMI Server. This server has only registered service. Also this machine runs a small web server which serves for codebase, where the JAR with Stubs is available.

      There is another Jar with Interfaces. This jar is to be used on RMI Server and RMI Client sides.

      When I run a small test class (jar with interfaces in CP) where I do lookup for the service, then do casting of Remote interface to my interface from mentioned jar and do invocation of remote methods - everything is fine.

      But as soon as I do the same under JBoss I'm getting the ClassCastException. When the program runs I see in log, that returned after lookup Remote object is my Stub class, which must be implementing the interface. But on the stage of casting I'm getting exception. The same with narrowing.

      Can anybody give me at least a direction where can be the problem?

      Please - I'm stuck. I really think that the problem someway connected to the environment where runs the client class - JBoss/Tomcat. But I don't know what can it be. Before, when the stubs where on the client side too - the code was working. It seems to be something with ClassLoading withing RMI. What can it be?

      Thanks in advance.

      P.S. I'm using JBoss-2.4.3_Tomcat-3.2.3 under 1.3 JVM.

        • 1. Re: JBoss -> RMI
          Andrew Boyd Novice

          What are you setting as your codebase?

          • 2. Re: JBoss -> RMI
            Dmitri Zamyslov Newbie

            When I start the RMIServer I set

            In jar are stubs.

            The problem is, that I have already done all this many times, when the RMI Client was running under the Java Program, but as soon as the client was brought in JBoss framework it doesn't work.

            • 3. Re: JBoss -> RMI
              Dmitri Zamyslov Newbie

              OK. Error is found.

              The problem was in ClassLoader.
              My system creates the RMI Client from URL ClassLoader by creating of the client erlier I did commented the initialization of the ContextClassLoader.

              In other hand the RMI Class Loader uses as basis Thread.getContextClassLoader(). When the context class loader was not inited, of cource, the context class loader didn't have needed interface. That's was the problem why it was saying that interface is not found, when this interface was not available at codebase. And that's why he was saying "classcastexception" when remote interface was available at codebase. Because the loaded class was in other class loader as the class to be casted to.

              so. any way thanx to all.