5 Replies Latest reply on Feb 17, 2004 6:19 PM by zolmed75

    ClassCastException thrown when looking up a remote home obje

    zolmed75 Newbie

      Hi. I'm getting a ClassCastException thrown in my client application when looking up a remote home object that is deployed on JBoss 3.x. When I deploy to JBoss 2.4.4, I do not have this problem. Does this have anything to do with the EJB container configuration settings? Thanks.

      Context ctx = new InititalContext();

      // this is where the ClassCastException is thrown when the bean is
      // deployed on JBoss 3.x, but NOT on JBoss 2.4.4
      SomeHomeObject home = (SomeHomeObject)ctx.lookup("...");

        • 1. Re: ClassCastException thrown when looking up a remote home
          harsh_pandit Newbie

          hi
          U can use the following syntex insetad of

          Context ctx = new InititalContext();

          u can write following code insetad of above line

          Properties props = new Properties();

          props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

          props.put(Context.PROVIDER_URL,"127.0.0.1");

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

          Context ctx = new InititalContext(props);

          I hope its working.
          and also check that u must set classpaht properly.


          • 2. Re: ClassCastException thrown when looking up a remote home
            bauschulte Newbie

            Hi,
            often i get a ClassCastException when the Stubs for the
            client not available or the stubs out of syn

            if you have a debugger, check the result of the EJBHome object

            you can make 2 steps to make the lookup for your ejb

            EJBHome home = context.lookup(..)

            check the homeobject in the debugger, you can see if the stubs available

            • 3. Re: ClassCastException thrown when looking up a remote home
              zolmed75 Newbie

              Actually, I've been looking around the JBoss forum and have seen a few other people with a similar problem as I'm having. Based on some of the replies I've seen, it seems to have something to do with the new class loading architecture of JBoss 3.x, which would explain why I don't have any problems on JBoss 2.4.4.
              What version of JBoss are you guys using? If you're using 3.0.7 or above, do you have any problems when lookup up remote home objects? If not, can you describe what your deployment environment is like (i.e. the classpath setting on the client, your standardjboss.xml file on the server, etc.). Thanks in advance.

              • 4. Re: ClassCastException thrown when looking up a remote home
                Darran Lofthouse Master

                Have you updated the client to use the client jars from the new version of JBoss instead of the old ones?

                Also are the server and client using the same JDK version?

                • 5. Re: ClassCastException thrown when looking up a remote home
                  zolmed75 Newbie

                  Both the client and server are using sdk1.4.2. What are the "client jars" you're reffering to? I thought the only thing the client needs are the remote EJB interfaces. Also, since JBoss uses dynamic proxies, I was under the impression that the only class that needs to be loaded at runtime during a lookup is the remote InvocationHandler class being used by the dynamic proxy. Is this correct or am I dreaming? Thanks in advance...