2 Replies Latest reply on Apr 29, 2003 11:24 AM by Raja

    ClassCastException in findByPrimaryKey call

    Steven Venable Newbie

      I am trying to merge two ejb jar files to make deployment easier on JBoss 3.0.5. One contains the package info.dpg.global and the other info.dpg.complaints. If both packages are jarred separately with their own descriptor files and deployed in the same ear file there are no exceptions and the web application can successfully use both sets of EJBs. I have tried merging the jar files and deploying them. Of course in this configuration only one set of descriptor files are used. All interfaces and descriptors are generated by xdoclet and appear to be correct. At any rate … I receive a series of errors for each bean during deployment like the following:

      09:50:27,506 INFO [EJBDeployer]
      Bean : UserProfile
      Section: 10.6.2
      Warning: The entity bean's class must implement, directly or indirectly, the jaax.ejb.EntityBean interface.

      Anyone know why this would happen?

      I have verified that each Bean class implements EntityBean ….
      public abstract class UserProfileBean implements javax.ejb.EntityBean {
      ........
      }

      Example from ejb-jar.xml:

      <ejb-name>UserProfile</ejb-name>
      info.dpg.global.interfaces.UserProfileHome
      info.dpg.global.interfaces.UserProfile
      <local-home>info.dpg.global.interfaces.UserProfileLocalHome</local-home>
      info.dpg.global.interfaces.UserProfileLocal

      <ejb-class>info.dpg.global.ejb.UserProfileBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>UserProfile</abstract-schema-name>
      <cmp-field >
      ........
      ........
      </cmp-field>
      <primkey-field>username</primkey-field>

      <ejb-local-ref >
      ........
      ........
      </ejb-local-ref>


      When a call is made to the home object's findByPrimary key a ClassCastException is thrown. This I assume is related to the missing interface:

      InitialContext jndiContext = new InitialContext();
      Object ref = jndiContext.lookup("java:comp/env/UserProfile");
      UserProfileHome userProfileHome = (UserProfileHome)
      PortableRemoteObject.narrow (ref, UserProfileHome.class);
      // next line throws the exception
      UserProfile profile = userProfileHome.findByPrimaryKey(username);
      ........

      java.lang.ClassCastException
      at org.jboss.ejb.EntityEnterpriseContext.(EntityEnterpriseContext.java:76)
      at org.jboss.ejb.plugins.EntityInstancePool.create(EntityInstancePool.java:86)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:184)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:78)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:228)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:62)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
      at org.jboss.ejb.Container.invoke(Container.java:730)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1058)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
      at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:198)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      at $Proxy81.findByPrimaryKey(Unknown Source)
      at filters.LoadUserFilter.loadUser(LoadUserFilter.java:62)
      at filters.LoadUserFilter.doFilter(LoadUserFilter.java:52)
      at filters.ComplaintsFilter.doFilter(ComplaintsFilter.java:32)
      at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:320)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:272)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:553)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1656)
      at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:549)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1606)
      at org.mortbay.http.HttpServer.service(HttpServer.java:862)
      at org.jboss.jetty.Jetty.service(Jetty.java:497)
      ........
      ........
      blah blah blah
      ........
      ........