2 Replies Latest reply on Dec 18, 2006 7:37 AM by Piotr Gaszcz

    ClassCastException

    Ravi Rao Newbie

      Hi,
      This would have been asked before but i could find the right thread which gives a solution to the following problem.

      I use -
      1)netBeans 5.5 to devlop and deploy EJB's
      2)jdk1.4

      Problem:

      A stateful session bean with the following :

      1)jboss.xml


      <enterprise-beans>

      <ejb-name>EnrollmentCartBean</ejb-name>
      <local-jndi-name>ejb/ECB</local-jndi-name>

      </enterprise-beans>


      2)ejb-jar.xml

      <display-name>EnrollmentCart</display-name>
      <ejb-name>EnrollmentCartBean</ejb-name>

      <local-home>com.testpack.stateful.EnrollmentLocalHome</local-home>
      com.testpack.stateful.EnrollmentLocal
      <ejb-class>com.testpack.stateful.EnrollmentCartBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Container</transaction-type>


      *** the <lo cal></lo cal> tag is not getting displayed in here !!! strange


      3) servlet code that tries to use the bean

      InitialContext ictx = new InitialContext();
      Object o = ictx.lookup("ejb/ECB");
      // Object o = ictx.lookup("ECB"); throws name not bound
      log.debug("object after look up:"+o); //** debug statement
      EnrollmentLocalHome home = (EnrollmentLocalHome)o;
      EnrollmentLocal ejbObject = home.create("client");


      I get the following erors

      **** 2006-12-15 11:51:36,781 DEBUG [com.testpack.webutil.Enroller] object after look up:ejb/ECBHome

      2006-12-15 11:51:36,781 ERROR [STDERR] java.lang.ClassCastException: $Proxy57
      2006-12-15 11:51:36,781 ERROR [STDERR] at com.testpack.webutil.Enroller.processRequest(Enroller.java:55)
      2006-12-15 11:51:36,781 ERROR [STDERR] at com.testpack.webutil.Enroller.doPost(Enroller.java:99)
      2006-12-15 11:51:36,781 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      2006-12-15 11:51:36,781 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      2006-12-15 11:51:36,781 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      2006-12-15 11:51:37,062 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      2006-12-15 11:51:37,062 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)


      Any help would be highly appreciated !!!

      Regards