1 Reply Latest reply on Jun 10, 2009 8:10 AM by Wolfgang Knauf

    ClassCastException @ PortableRemoteObject.narrow

    Juergen Weber Newbie


      I have a deployed an ejb and an exploded web application, that should call the ejb.

      On looking up the EJB home interface from the webapp there is

      Caused by: java.lang.ClassCastException: $Proxy235 cannot be cast to org.omg.CORBA.Object
      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)

      Object o = context.lookup(jndiName);
      MyHome home = (MyHome) PortableRemoteObject.narrow(o, MyHome.class);

      Using the remote debugger I found that the result from the JNDI lookup is from the EJB's classloader and MyHome from the WAR classloader.

      As MyHome.class is needed in the EJB and in the WAR, what is the recommended place for JBoss 5.1 to put the common classes in?

      I removed MyHome.class from the WAR, then it worked (and the MyHome.class was pulled in from the EJB). But it seems strange to have a WAR to use classes from the EJB. And why does the WAR see the EJB's classes?