0 Replies Latest reply on Dec 9, 2003 3:04 AM by eckhard

    ClassCastException in generated CMP Proxy

    eckhard Newbie

      Hi all,

      I m trying to setup a EJB based application using XDoclet. I ve created one EntityBean for every DB-Entity. The second step was to create a TestClient which connects, using the JNDI Name, to a SessionBean.
      Now the SessionBean uses the Local Interface to get the Value Object of the specified entity. The ValueObjects will be put into a Collection and will be sent back to the Client.

      The error which occured is in a generated CMP class.
      thanx a lot and krgds
      eckhard

      Some piece of code:

      TestClient:

      public static void main(String[] args) {
      /*TestClient t = new TestClient();
      //t.printGangsterMdr();
      t.testRelations2();
      */
      Properties props = new Properties();

      System.setProperty(
      InitialContext.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      System.setProperty(
      InitialContext.PROVIDER_URL,
      "jnp://servername:1099");
      TestClient t = new TestClient();
      t.init();
      }
      private MdrStatusViewSessionHome getMdrStatusView()
      throws NamingException {
      return (MdrStatusViewSessionHome) getContext().lookup(
      MdrStatusViewSessionHome.JNDI_NAME);
      }
      private void init() {
      try {
      System.out.println("[Method] Init");
      MdrStatusViewSession sess = getMdrStatusView().create();
      Collection c = sess.getDataFeeds();
      Iterator it = c.iterator();
      while (it.hasNext()) {
      DataFeedValue dv = (DataFeedValue) it.next();
      System.out.println(dv.toString());
      }
      } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (NamingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (CreateException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      }

      SessionBean:

      /**
      * @ejb.interface-method
      */
      public ArrayList getDataFeeds() {
      ArrayList dfs = new ArrayList();
      try {
      //Collection c = DataFeedUtil.getHome().findAll();
      Collection c = this.getDataFeedLocalHome().findAll();
      System.out.println("Datafeeds: " + c.size());
      Iterator it = c.iterator();
      while (it.hasNext()) {
      DataFeedLocal df = (DataFeedLocal) (it.next());
      DataFeedValue dv = df.getDataFeedValue();
      }
      } catch (FinderException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (NamingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      return dfs;
      }


      09:18:50,841 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract com.ubs.gear.ssrd.mdr.interfaces.DataFeedValue com.ubs.gear.ssrd.mdr.interfaces.DataFeedLocal.getDataFeedValue(), causedBy:
      java.lang.ClassCastException
      at com.ubs.gear.ssrd.mdr.ejb.DataFeedCMP$Proxy.getDataFeedSpecification()
      at com.ubs.gear.ssrd.mdr.ejb.DataFeedCMP.getDataFeedValue(DataFeedCMP.java:117)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1095)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:71)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:277)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:114)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:490)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:375)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy64.getDataFeedValue(Unknown Source)
      at com.ubs.gear.ssrd.mdr.ejb.MdrStatusViewSessionBean.getDataFeeds(MdrStatusViewSessionBean.java:110)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:536)