3 Replies Latest reply on Oct 21, 2008 10:40 AM by eli dzah

    BMP Bean deployed but ClassCastException

    eli dzah Newbie

      Hi,
      I realize an entity-bean (Bean managed persistence) and deploy it correctly but when i try to get the Home interface, I got a ClassCastException.

      Has anyone an Idea of the problem?
      Here under i report pieces of the code I hope are enough to resolve the problem!

      ############client code ##################
      Client code that generate the exception:
      Context jndiContext = getInitialContext();

      Object ref = jndiContext.lookup("SavingsAccountHomeRemote");

      SavingsAccountHomeRemote home = (SavingsAccountHomeRemote)
      (PortableRemoteObject.narrow(ref,SavingsAccountHomeRemote.class));
      #############ejb-jar.xml (essential)##########
      <ejb-name>SavingsAccountEJB</ejb-name>
      com.eli.beans.SavingsAccountHomeRemote
      com.eli.beans.SavingsAccount
      <ejb-class>com.eli.beans.SavingsAccountBean</ejb-class>
      <persistence-type>Bean</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      ############# jboss.xml (essential) ###########

      <enterprise-beans>

      <ejb-name>SavingsAccountEJB</ejb-name>
      <jndi-name>SavingsAccountHomeRemote</jndi-name>

      </enterprise-beans>

      ############ Deployment confirmation ###########
      23:35:45,640 INFO [EjbModule] Deploying SavingsAccountEJB
      23:35:45,687 INFO [ProxyFactory] Bound EJB Home 'SavingsAccountEJB' to jndi 'SavingsAccountHomeRemote'

        • 1. Re: BMP Bean deployed but ClassCastException
          eli dzah Newbie

          Excuse me. Following i report the error logged:

          00:10:56,437 ERROR [STDERR] java.lang.ClassCastException
          00:10:56,437 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
          00:10:56,437 ERROR [STDERR] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
          00:10:56,437 ERROR [STDERR] at com.eli.clients.EjbHttpClient.doPost(EjbHttpClient.java:82)
          00:10:56,437 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
          00:10:56,437 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          00:10:56,437 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          00:10:56,437 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
          00:10:56,437 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          00:10:56,437 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          00:10:56,437 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
          00:10:56,437 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
          00:10:56,437 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
          00:10:56,437 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
          00:10:56,437 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
          00:10:56,437 ERROR [STDERR] Caused by: java.lang.ClassCastException: $Proxy77
          00:10:56,437 ERROR [STDERR] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)
          00:10:56,437 ERROR [STDERR] ... 22 more

          • 3. Re: BMP Bean deployed but ClassCastException
            eli dzah Newbie

            Many thanks.

            I was almost desperate.

            The link is very useful!!!

            My situation was the following:
            Servlet client of the EJB and the EJB on the same Server (ClassLoading problem).
            I resolve the problem setting the Class-Path property in the MANIFEST of the Client including the original jar file of the EJB.

            You save me a lot of time.

            By