No such entity WHY?
jarva55 Feb 21, 2005 9:54 AMHi!!!
When i try to execute "findByPrimaryKey" on my CMP bean, i've this exception:
javax.ejb.ObjectNotFoundException: No such entity! at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntityCommand.execute(JDBCFindEntityCommand.java:50) at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntity(JDBCStoreManager.java:589) at org.jboss.ejb.plugins.CMPPersistenceManager.findEntity(CMPPersistenceManager.java:300) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntity(CachedConnectionInterceptor.java:298) at org.jboss.ejb.EntityContainer.findSingleObject(EntityContainer.java:1086) at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:663) 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.invocation.Invocation.performCall(Invocation.java:345) at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1113) at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90) at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:192) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:212) at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90) at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:117) at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61) at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28) at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313) at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:126) at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:101) at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93) at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:508) at org.jboss.ejb.Container.invoke(Container.java:891) at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:342) at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118) at $Proxy135.findByPrimaryKey(Unknown Source) at com.acotelsa.qnecta.server.dao.cliente.ejb.DAOCliente.actualizarBalanceEntity(DAOCliente.java:190) 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.invocation.Invocation.performCall(Invocation.java:345) at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185) at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113) at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:123) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122) at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624) at org.jboss.ejb.Container.invoke(Container.java:870) 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.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80) at org.jboss.mx.server.Invocation.invoke(Invocation.java:72) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642) at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805) at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406) 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:534)
My java code, specially primary key, is like that (with Xdoclet):
public abstract class DAOEntityBalance implements EntityBean { /** * El contexto de la sesión del EJB */ private EntityContext context; /** * @ejb.interface-method view-type = "both" * @ejb.persistence column-name = "ID_CLIENTE" jdbc-type = "NUMERIC" * @ejb.pk-field */ public abstract Long getIdCliente(); /** * @ejb.interface-method view-type = "both" */ public abstract void setIdCliente(Long idCliente); /** * @ejb.interface-method view-type = "both" * @ejb.persistence column-name = "BALANCE" ......
Ejb-jar.xml:
<entity > <description><![CDATA[DAOEntityBalance EJB]]></description> <display-name>DAOEntityBalance</display-name> <ejb-name>DAOEntityBalance</ejb-name> <home>com.acotelsa.qnecta.server.dao.balance.entity.DAOEntityBalanceHome</home> <remote>com.acotelsa.qnecta.server.dao.balance.entity.DAOEntityBalanceRemote</remote> <local-home>com.acotelsa.qnecta.server.dao.balance.entity.DAOEntityBalanceLocalHome</local-home> <local>com.acotelsa.qnecta.server.dao.balance.entity.DAOEntityBalanceLocal</local> <ejb-class>com.acotelsa.qnecta.server.dao.balance.entity.DAOEntityBalance</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>java.lang.Long</prim-key-class> <reentrant>false</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>TF_BALANCE</abstract-schema-name> <cmp-field > <description><![CDATA[]]></description> <field-name>idCliente</field-name> </cmp-field> <cmp-field > <description><![CDATA[]]></description> <field-name>balance</field-name> </cmp-field> <cmp-field > <description><![CDATA[]]></description> <field-name>credito</field-name> </cmp-field> <cmp-field > <description><![CDATA[]]></description> <field-name>limite</field-name> </cmp-field> <cmp-field > <description><![CDATA[]]></description> <field-name>controlLimite</field-name> </cmp-field> <primkey-field>idCliente</primkey-field> <env-entry> <env-entry-name>/qnecta/bbdd/jdbc/debugSQL</env-entry-name> <env-entry-type>java.lang.Boolean</env-entry-type> <env-entry-value><![CDATA[true]]></env-entry-value> </env-entry> <resource-ref > <res-ref-name>/qnecta/bbdd/jdbc/OracleDS_QPLANES</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </entity>
Jboss.xml:
<entity> <ejb-name>DAOEntityBalance</ejb-name> <jndi-name>/qnecta/ejb/DAOEntityBalanceHome</jndi-name> <local-jndi-name>/qnecta/ejb/DAOEntityBalanceLocalHome</local-jndi-name> <resource-ref> <res-ref-name>/qnecta/bbdd/jdbc/OracleDS_QPLANES</res-ref-name> <jndi-name>/qnecta/bbdd/jdbc/OracleDS_QPLANES</jndi-name> </resource-ref> <method-attributes> </method-attributes> </entity>
And jbosscmp-jdbc.xml:
<entity> <ejb-name>DAOEntityBalance</ejb-name> <table-name>TF_BALANCE</table-name> <cmp-field> <field-name>idCliente</field-name> <column-name>ID_CLIENTE</column-name> </cmp-field> <cmp-field> <field-name>balance</field-name> <column-name>BALANCE</column-name> </cmp-field> <cmp-field> <field-name>credito</field-name> <column-name>CREDITO</column-name> </cmp-field> <cmp-field> <field-name>limite</field-name> <column-name>LIMITE</column-name> </cmp-field> <cmp-field> <field-name>controlLimite</field-name> <column-name>CONTROL_LIMITE</column-name> </cmp-field> <!-- jboss 3.2 features --> <!-- optimistic locking does not express the exclusions needed --> </entity>
Why have i this exception??? i try to use another key name, but it doesn't run. What is wrong, i can't find it!
Thanks. Best regards.