4 Replies Latest reply on Jul 27, 2004 2:33 PM by cbaes

    ejbSelect error during iteration

    cbaes Newbie

      Everytime I iterate through the list returned by my ejbSelectStudents I get an error, see below. I've been researching this for two days and can't find any referrence solutions. Does anyone know why this is happening?

      session remote code:

      public void getStudents(Integer courseCode)
      throws EJBException, RemoteException {
      try
      {
      .
      .
      Collection list =
      courseLocalHome.queryStudents(courseCode);
      Iterator iter = list.iterator();

      // the list is coming back with two students.....but on System.out below I'm getting the error.

      while(iter.hasNext())
      {
      student = (Student)iter.next();
      System.out.println(student.getName());
      }
      }
      catch (Exception ex)
      {
      e.printStackTrace(out);
      }
      }


      local ejb code:

      .
      .
      public Collection ejbHomeQueryStudents()
      throws FinderException
      {
      return ejbSelectStudents();
      }

      .
      .


      13:42:32,925 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.lang.Integer com.school.local.interfaces.Students.getName(), causedBy:
      javax.ejb.NoSuchObjectLocalException: EJB home methods are not allowed to access CMP or CMR fields: methodName=getStudentOID
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:142)
      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:315)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      ........

        • 1. Re: ejbSelect error during iteration
          Alexey Loubyansky Master

          Are you sure the exception is thrown during iteration? It says methodName=getStudentOID, not getName. Post the whole stacktrace.

          • 2. Re: ejbSelect error during iteration
            cbaes Newbie

            If I remove the "getName()" and just print out 'student' it doesn't crash. I get the JNDI name:primaryKey displayed on the screen.

            while(iter.hasNext())
            {
            student = (Student)iter.next();
            System.out.println(student);
            }

            It also works if I use student.getPrimaryKey(), or student.getEJBLocalHome().

            I think it can't find the Student local object,...as mentioned on the error... but I'm not getting any casting error on my iter.next(). strange...

            causedBy:javax.ejb.NoSuchObjectLocalException:

            • 3. Re: ejbSelect error during iteration
              cbaes Newbie

              the entire stacktrace

              -----------

              10:33:21,223 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.lang.Integer com.school.local.interfaces.Students.getName(), causedBy:
              javax.ejb.NoSuchObjectLocalException: EJB home methods are not allowed to access CMP or CMR fields: methodName=getStudentOID
              at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:142)
              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:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              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:484)
              at org.jboss.ejb.Container.invoke(Container.java:723)
              at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
              at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
              at $Proxy47.getName(Unknown Source)
              at com.school.StudentTestSessionBean.testA1(StudentTestSessionBean.java:114)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              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:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              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:723)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
              at sun.rmi.transport.Transport$1.run(Unknown Source)
              at java.security.AccessController.doPrivileged(Native Method)
              at sun.rmi.transport.Transport.serviceCall(Unknown Source)
              at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
              at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
              at java.lang.Thread.run(Unknown Source)
              10:33:21,253 ERROR [LogInterceptor] EJBException, causedBy:
              javax.ejb.TransactionRolledbackLocalException: EJB home methods are not allowed to access CMP or CMR fields: methodName=getStudentOID; CausedByException is:
              EJB home methods are not allowed to access CMP or CMR fields: methodName=getStudentOID
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:204)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              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:484)
              at org.jboss.ejb.Container.invoke(Container.java:723)
              at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
              at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
              at $Proxy47.getName(Unknown Source)
              at com.school.StudentTestSessionBean.testA1(StudentTestSessionBean.java:114)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              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:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              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:723)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
              at sun.rmi.transport.Transport$1.run(Unknown Source)
              at java.security.AccessController.doPrivileged(Native Method)
              at sun.rmi.transport.Transport.serviceCall(Unknown Source)
              at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
              at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
              at java.lang.Thread.run(Unknown Source)
              javax.ejb.NoSuchObjectLocalException: EJB home methods are not allowed to access CMP or CMR fields: methodName=getStudentOID
              at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:142)
              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:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              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:484)
              at org.jboss.ejb.Container.invoke(Container.java:723)
              at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
              at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
              at $Proxy47.getName(Unknown Source)
              at com.school.StudentTestSessionBean.testA1(StudentTestSessionBean.java:114)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              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:315)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
              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:723)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
              at sun.rmi.transport.Transport$1.run(Unknown Source)
              at java.security.AccessController.doPrivileged(Native Method)
              at sun.rmi.transport.Transport.serviceCall(Unknown Source)
              at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
              at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
              at java.lang.Thread.run(Unknown Source)

              • 4. Re: ejbSelect error during iteration
                cbaes Newbie

                I've renamed the method name in the session remote code to testA1 from the original getStudents....shown on the stacktrace.

                session remote code:

                public void testA1(Integer courseCode)
                throws EJBException, RemoteException {
                try
                {
                .
                .
                Collection list =
                courseLocalHome.queryStudents();
                Iterator iter = list.iterator();

                // the list is coming back with two students.....but on System.out below I'm getting the error.

                while(iter.hasNext())
                {
                student = (Students)iter.next();
                System.out.println(student.getName());
                }
                }
                catch (Exception ex)
                {
                e.printStackTrace(out);
                }
                }


                local ejb code:

                .
                .
                public Collection ejbHomeQueryStudents()
                throws FinderException
                {
                return ejbSelectStudents();
                }

                .
                .