1 Reply Latest reply on Sep 27, 2005 9:59 PM by kourosh bagheri

    ClassCastException while narrowing....

    Daniel Nunes Newbie

      Hell... I looked up over thousands of examples and it's just like everyone else's.

      I'm having problems doing this:

      private DataBaseHome home;
      private String selectAll = "SELECT a.nome,b.nome from a author,b book where a.id = b.auth_id";
      
       public void init(ServletConfig config) throws ServletException {
       try {
       Context context = new InitialContext();
       Object ref = context.lookup("java:/comp/env/ejb/DataBase");
       home = (DataBaseHome) (PortableRemoteObject.narrow(ref,DataBaseHome.class));
       }catch (Exception ex) {
       System.out.println("Error at GeraPage");
       ex.printStackTrace();
       System.out.println(ex.toString());
       }
       }
      


      It throws the following:

      10:13:55,036 INFO [EARDeployer] Started J2EE application: file:/C:/jboss-4.0.2/server/all/deploy/DataBaseApp.ear
      10:14:12,632 INFO [STDOUT] Error at GeraPage
      10:14:26,632 INFO [STDOUT] java.lang.ClassCastException
      10:14:27,173 INFO [STDOUT] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
      10:14:27,183 INFO [STDOUT] at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
      10:14:27,183 INFO [STDOUT] at teste.servlets.GeraPageServlet.init(GeraPageServlet.java:55)
      10:14:27,183 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
      10:14:27,203 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
      10:14:27,203 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
      10:14:27,213 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      10:14:27,213 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      10:14:27,213 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
      10:14:27,223 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:81)
      10:14:27,223 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      10:14:27,233 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      10:14:27,233 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      10:14:27,233 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      10:14:27,233 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      10:14:27,243 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      10:14:27,253 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      10:14:27,253 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      10:14:27,253 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      10:14:27,263 INFO [STDOUT] at java.lang.Thread.run(Unknown Source)
      10:14:27,273 INFO [STDOUT] Caused by: java.lang.ClassCastException: $Proxy60
      10:14:27,273 INFO [STDOUT] ... 20 more
      



      Does anyone knows a workaround to this??

        • 1. Re: ClassCastException while narrowing....
          kourosh bagheri Newbie

          Hi!
          I'm working with JBoss 4.0.3, EJB 3.0 and Servlets.
          I have a SFSB, with a @Remote business interface, and I get the same error, trying to get the SFSB in the servlet to work with it.

          My SFSB looks like this:
          @Stateful
          public class CartBean implements Carts{
          ...

          The Business Interface :

          @Remote
          public interface Carts {
          ...

          And finaly the servlet:
          Carts cartBean = null;
          cartBean = (Carts) context.lookup(Carts.class.getName());
          ...
          Wenn I restart JBoss and do not change the sourcecode, it works fine, but if I change something and insert the changed code (as ear file), I get this error:
          "java.lang.ClassCastException: $Proxy147"
          And after a new restart of JBoss the exceptions run off!!
          Does someone know the reason?