3 Replies Latest reply on Dec 18, 2003 2:41 AM by pwijntjes

    Final word on ClassCastException???

    Adam Smith Newbie

      jboss 3.0.4
      tomcat 4.1.12 (embedded)
      jdk 1.4.1

      Have seen many posts on the ClassCastException with PortableRemoteObject.narrow, but no definitive answers. Tried to modify the classloader, but it diddn't help. Tried without PortableRemoteObject.narrow, got
      java.lang.ClassCastException
      at org.apache.jsp.secondEJB_jsp._jspService(secondEJB_jsp.java:70)
      which is:
      AddressHome addrhome = (AddressHome) ctx.lookup("ejb/Address");

      To reiterate, my original code in .jsp looks like this:

      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      props.put(Context.PROVIDER_URL, "localhost:1099");
      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      DirContext ctx = new InitialDirContext(props);

      Object addrref = ctx.lookup("ejb/Address");

      AddressHome addrhome = (AddressHome)PortableRemoteObject.narrow(addrref, AddressHome.class);


      My exception is this:

      java.lang.ClassCastException
      at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)