10 Replies Latest reply on May 16, 2008 10:16 AM by Burkhard Vogt

    ClassCastException with EJBs

    spelux Newbie

      Hi i'm having some problems deplying servlets. This is the error:
      java.lang.ClassCastException
      com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
      javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
      edu.nyu.pdsg.tpcw.web.HomeServlet.init(HomeServlet.java:44)
      javax.servlet.GenericServlet.init(GenericServlet.java:211)
      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      java.lang.Thread.run(Thread.java:534)

      And this is the servlet code:
      [...]
      Object objref;
      try {
      objref = (new InitialContext()).lookup("java:comp/env/ejb/ShoppingCart");
      //objref = (new InitialContext()).lookup("TheShoppingCart");
      } catch (NamingException ne) {
      throw new ServletException(ne.getMessage());
      }
      cartHome = (ShoppingCartHome)PortableRemoteObject.narrow(objref, ShoppingCartHome.class);

      super.init();
      }
      [...]

      what is the problem???

      I'm using JBoss 4.0.2 and jdk 1.5