0 Replies Latest reply on Nov 3, 2003 9:21 AM by dirksklarek

    Entity not found

    dirksklarek Newbie

      I'm running JBoss 3.2.2RC3(200308241317) with tomcat on W2000 and mysql.
      I have an entity bean with a primary key name and companyname.
      I define a finder method like this:
      ...
      public Collection findAll4Company(String company) throws FinderException;
      ...

      The deployment descriptor is like this:
      ...

      <display-name>Employee-Entity</display-name>
      <ejb-name>Employee</ejb-name>
      <local-home>de.rds.tr.business.employee.ejb.entity.EmployeeLocalHome</local-home>
      de.rds.tr.business.employee.ejb.entity.EmployeeLocal
      <ejb-class>de.rds.tr.business.employee.ejb.entity.EmployeeBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>de.rds.tr.business.employee.ejb.entity.PK</prim-key-class>
      false
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>employee</abstract-schema-name>
      <cmp-field><field-name>name</field-name></cmp-field>>
      <cmp-field><field-name>companyname</field-name></cmp-field>>
      <cmp-field><field-name>password</field-name></cmp-field>>
      <cmp-field><field-name>anrede</field-name></cmp-field>>
      <cmp-field><field-name>email</field-name></cmp-field>>
      <cmp-field><field-name>role</field-name></cmp-field>>

      <query-method>
      <method-name>findAll4Company</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[ SELECT OBJECT( emp ) FROM employee emp WHERE emp.companyname = ?1 ]]>

      </ejb-ql>




      ...


      The Clientcode to the entity bean is wrapped within a FacadeBean and is like this


      ...
      Collection companyCollection;
      EmployeeLocal empLocal=null;

      try {
      companyCollection = employeeLocalHome.findAll4Company(name);
      if (companyCollection != null&&companyCollection.size()>0){
      logger.debug("habe "+companyCollection.size()+" Employees gefunden.");
      ret = new EmployeeVO[companyCollection.size()];
      int i = 0;
      for (Iterator iter = companyCollection.iterator();
      iter.hasNext();
      ) {
      Object o = iter.next();
      empLocal = (EmployeeLocal) o;
      EmployeeVO cvo = new EmployeeVO();
      cvo.setName(empLocal.getName());
      cvo.setAnrede(empLocal.getAnrede());
      cvo.setCompanyName(empLocal.getCompanyname());
      cvo.setEmail(empLocal.getEmail());
      cvo.setPassword(empLocal.getPassword());
      cvo.setRole(empLocal.getRole());
      ret = cvo;
      i++;
      }
      }
      } catch (FinderException e) {
      throw new BusinessException(this, e.getMessage());
      }
      ...

      Now my problem!
      When there is only one record in the db, everything is fine and i get the values of this record.
      But when there is more than one record in the db, I get the following exception:

      2003-11-03 16:42:02,559 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Employee:147] DEBUG Executing SQL: SELECT name, companyname,password, anrede, email, role FROM employee WHERE (name=? AND companyname=?) OR (name=? AND companyname=?)
      2003-11-03 16:42:02,569 ERROR [org.jboss.ejb.plugins.LogInterceptor:290] ERROR TransactionRolledbackLocalException in method: public abstract java.lang.String de.rds.tr.business.employee.ejb.entity.EmployeeLocal.getName(), causedBy:
      javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=de.rds.tr.business.employee.ejb.entity.PK@1486b51
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:158)
      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:353)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy141.getName(Unknown Source)
      at de.rds.tr.business.ejb.session.FacadeBean.getEmployees4Company(FacadeBean.java:188)
      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:186)
      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.local.LocalInvoker.invoke(LocalInvoker.java:101)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      at $Proxy137.getEmployees4Company(Unknown Source)
      at de.rds.tr.business.Delegate.Delegate.getEmployees4Company(Delegate.java:85)
      at de.rds.tr.request.MasterMainHandler.handleRequest(MasterMainHandler.java:40)
      at de.rds.util.web.controller.FrontController.doGet(FrontController.java:202)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:228)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:263)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:360)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:604)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:562)
      at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:679)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
      at java.lang.Thread.run(Thread.java:536)

      Thanks for your help