0 Replies Latest reply on Jul 2, 2010 6:14 AM by simafe_2000

    ClassCastException after JNDI lookup

    simafe_2000

      Hello all.

       

      I have two instances of JBoss 4.0.5 running on my computer and on each one I have deployed an ear.
      From one instance I am connecting to the JNDI tree of the other instance to lookup an EJB:

       

      Properties h = System.getProperties();

      h.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.HttpNamingContextFactory");

      h.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

      h.setProperty(Context.PROVIDER_URL, http://localhost:9000/invoker/JNDIFactory);

      Context ctx = new InitialContext(h);

      Object objref = ctx.lookup("ejb/mif/ListeAllegateFacade");

      EJBHome home = (EJBHome)PortableRemoteObject.narrow(objref, ListeAllegateFacadeHome.class);

       

      During the narrowing, on the last line, I get a ClassCastException

       

      The type of the object I receive from the lookup is a Proxy$64 which doesn't implement my interface, even if the JNDI view of the second instance shows that there is an entry that implements my interface (in the global JNDI namespace):

       

      From jmx-console:

       

      ...

      +- ejb

        |   +- mif

        |   |   +- ListeAllegateFacade (proxy: $Proxy57 implements interface ...ListeAllegateFacadeHome,interface javax.ejb.Handle)

      ...

       

      Over the last days I have spent a lot of time trying to understand and to fix it, but with no result
      Searching the net for a solution I came over a lot of useful articles, made what they said and checked everything.
      Here is what I have done, in all combinations, not neccessary all of them in the same time:
      - I have checked that there are no duplicated entries of my class (ListeAllegateFacadeHome) in my ear files.
      - I have checked that there are no javax.ejb.* classes on my ear files.
      - I have included the jars from "client" directory of Jboss on the "lib" directory of my server (on the first instance).
      (Is it correct? I mean, in order to transform the first instance in a client of the second instance do I have to put the jars from the "client" directory of JBoss in the classpath of the first instance, which is the same as placing them in the "lib" directory of my server from the the first instance?)

       

      Any help will be highly appreciated.

       

      Best regards,
      Felix