1 Reply Latest reply on Nov 30, 2005 5:16 AM by Darran Lofthouse

    help with ClassCastException

    Jim Owen Newbie

      Hi,

      I'm getting a class cast exception when attempting to create an instance of my LocalHome object that I have not been able to figure out. It's probably something pretty simple, but I just haven't been able to see it. I'm using JBoss 4.0.3.

      Here's the code that is being executed in my servlet:

      Object obj = null;
      try
      {
      obj = ctx.lookup("java:comp/env/FSCApplicantLocal");
      FSCApplicantLocalHome fsc_applicant_home = (FSCApplicantLocalHome)PortableRemoteObject.narrow(obj, FSCApplicantLocalHome.class);
      applicant = fsc_applicant_home.findByPrimaryKey(new Long(quoteNo));
      }
      catch(Exception _e)
      {
      _e.printStackTrace();
      throw _e;
      }


      Here's the jboss.xml:

      <ejb-name>FSCApplicantBean</ejb-name>
      <local-jndi-name>ejb/local/FSCApplicantLocal</local-jndi-name>
      <ejb-local-ref>
      <ejb-ref-name>FSCApplicantLocal</ejb-ref-name>
      <local-jndi-name>ejb/FSCApplicantLocal</local-jndi-name>
      </ejb-local-ref>



      Here's the ejb-jar.xml:

      <![CDATA[FSC Applicant Entity Bean (CMP)]]>
      <display-name>FSCApplicantBean</display-name>
      <ejb-name>FSCApplicantBean</ejb-name>
      <local-home>com.InsureSuite.FSCExport.FSCApplicantLocalHome</local-home>
      com.InsureSuite.FSCExport.FSCApplicantLocal
      <ejb-class>com.InsureSuite.FSCExport.impl.FSCApplicantBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Long</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>FSCApplicant</abstract-schema-name>

      /****** CUT ALL THE CMP DEFS FROM HERE *********/

      <primkey-field>quote_no</primkey-field>
      <ejb-local-ref >
      <ejb-ref-name>FSCApplicantLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>com.InsureSuite.FSCExport.FSCApplicantLocalHome</local-home>
      com.InsureSuite.FSCExport.FSCApplicantLocal
      <ejb-link>FSCApplicantBean</ejb-link>
      </ejb-local-ref>

      <![CDATA[Find all]]>
      <query-method>
      <method-name>findAll</method-name>
      <method-params>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[select object (c) from FSCApplicant as c]]></ejb-ql>



      Here's the web.xml:
      <ejb-local-ref >
      <ejb-ref-name>FSCApplicantLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>com.InsureSuite.FSCExport.FSCApplicantLocalHome</local-home>
      com.InsureSuite.FSCExport.FSCApplicantLocal
      <ejb-link>FSCApplicantBean</ejb-link>
      </ejb-local-ref>


      Here's the jboss-web.xml:
      <ejb-local-ref >
      <ejb-ref-name>FSCApplicantLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>com.InsureSuite.FSCExport.FSCApplicantLocalHome</local-home>
      com.InsureSuite.FSCExport.FSCApplicantLocal
      <ejb-link>FSCApplicantBean</ejb-link>
      </ejb-local-ref>


      And finally, here's the stack trace:

      10:47:39,776 INFO [STDOUT] java.lang.ClassCastException
      10:47:39,776 INFO [STDOUT] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
      10:47:39,776 INFO [STDOUT] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
      10:47:39,776 INFO [STDOUT] at com.InsureSuite.FSCExport.FSCQuote.init(FSCQuote.java:163)
      10:47:39,776 INFO [STDOUT] at com.InsureSuite.FSCExport.FSCQuote.(FSCQuote.java:68)
      10:47:39,776 INFO [STDOUT] at org.apache.jsp.test_jsp._jspService(org.apache.jsp.test_jsp:58)
      10:47:39,776 INFO [STDOUT] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      10:47:39,776 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      10:47:39,776 INFO [STDOUT] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      10:47:39,776 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      10:47:39,776 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      10:47:39,776 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:47:39,776 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      10:47:39,776 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      10:47:39,776 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      10:47:39,776 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:81)
      10:47:39,776 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      10:47:39,776 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      10:47:39,776 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      10:47:39,776 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      10:47:39,776 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      10:47:39,776 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      10:47:39,776 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
      10:47:39,776 INFO [STDOUT] Caused by: java.lang.ClassCastException: $Proxy72
      10:47:39,776 INFO [STDOUT] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
      10:47:39,776 INFO [STDOUT] ... 30 more
      10:47:39,776 INFO [STDOUT] WARNING: The applicant entity could not be initialized!: null


      Any help would be appreciated.

      Thanks,

      Jim