users@glassfish.java.net

findByPrimaryKey returns JDO76012: Object not found for this Object

From: <glassfish_at_javadesktop.org>
Date: Tue, 12 Jun 2007 16:36:23 PDT

Hello,

I try to execute this code:

customer = customerHome.findByPrimaryKey(login);

This code returns this exception:

Bean 'CustomerBean' method ejbFindByPrimaryKey:
com.sun.jdo.api.persistence.support.JDOUserException: JDO76012: Object not found for this ObjectId.
NestedException: java.lang.NullPointerException
at com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerImpl.getObj ectById(PersistenceManagerImpl.java:662)
at com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerWrapper.get ObjectById(PersistenceManagerWrapper.java:263)
at data.CustomerBean_598693101_ConcreteImpl.ejbFindByPrimaryKey(CustomerBean_59869 3101_ConcreteImpl.java:252)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurit yManager.java:1050)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java: 2766)
at com.sun.ejb.containers.EntityContainer.invokeFindByPrimaryKey(EntityContainer.j ava:756)
at com.sun.ejb.containers.EJBLocalHomeInvocationHandler.invoke(EJBLocalHomeInvocat ionHandler.java:220)
at $Proxy113.findByPrimaryKey(Unknown Source)
at agency.AdvertiseBean.ejbCreate(AdvertiseBean.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurit yManager.java:1050)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java: 2766)
at com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocationHandler .java:229)
at $Proxy111.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java :121)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServa nt(CorbaServerRequestDispatcherImpl.java:650)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaS erverRequestDispatcherImpl.java:193)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Co rbaMessageMediatorImpl.java:1705)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMess ageMediatorImpl.java:1565)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessag eMediatorImpl.java:947)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Reque stMessage_1_2.java:178)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMess ageMediatorImpl.java:717)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOr ChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrCh annelConnectionImpl.java:1270)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Thread PoolImpl.java:479)

NestedStackTrace:
java.lang.NullPointerException
at com.sun.jdo.spi.persistence.support.sqlstore.SQLStateManager.markKeyFieldsPrese nt(SQLStateManager.java:1688)
at com.sun.jdo.spi.persistence.support.sqlstore.SQLStateManager.reload(SQLStateMan ager.java:1168)
at com.sun.jdo.spi.persistence.support.sqlstore.SQLStateManager.reload(SQLStateMan ager.java:1136)
at com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerImpl.getObj ectById(PersistenceManagerImpl.java:651)
at com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerWrapper.get ObjectById(PersistenceManagerWrapper.java:263)
at data.CustomerBean_598693101_ConcreteImpl.ejbFindByPrimaryKey(CustomerBean_59869 3101_ConcreteImpl.java:252)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurit yManager.java:1050)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java: 2766)
at com.sun.ejb.containers.EntityContainer.invokeFindByPrimaryKey(EntityContainer.j ava:756)
at com.sun.ejb.containers.EJBLocalHomeInvocationHandler.invoke(EJBLocalHomeInvocat ionHandler.java:220)
at $Proxy113.findByPrimaryKey(Unknown Source)
at agency.AdvertiseBean.ejbCreate(AdvertiseBean.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurit yManager.java:1050)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java: 2766)
at com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocationHandler .java:229)
at $Proxy111.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java :121)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServa nt(CorbaServerRequestDispatcherImpl.java:650)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaS erverRequestDispatcherImpl.java:193)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Co rbaMessageMediatorImpl.java:1705)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMess ageMediatorImpl.java:1565)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessag eMediatorImpl.java:947)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Reque stMessage_1_2.java:178)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMess ageMediatorImpl.java:717)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOr ChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrCh annelConnectionImpl.java:1270)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Thread PoolImpl.java:479)


This is the ejb definition of CustomerBean in ejb-jar.xml:

<entity>
<display-name>CustomerBean</display-name>
<ejb-name>CustomerBean</ejb-name>
<local-home>data.CustomerLocalHome</local-home>
<local>data.CustomerLocal</local>
<ejb-class>data.CustomerBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Customer</abstract-schema-name>
<cmp-field>
<description>no description</description>
<field-name>login</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>email</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>address2</field-name>
</cmp-field>
<cmp-field>
<description>no description</description>
<field-name>address1</field-name>
</cmp-field>
<primkey-field>login</primkey-field>
<ejb-local-ref>
<ejb-ref-name>ejb/JobLocal</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>data.JobLocalHome</local-home>
<local>data.JobLocal</local>
<ejb-link>JobBean</ejb-link>
</ejb-local-ref>
<security-identity>
<description></description>
<use-caller-identity></use-caller-identity>
</security-identity>
<query>
<description></description>
<query-method>
<method-name>findAll</method-name>
<method-params />
</query-method>
<ejb-ql>SELECT OBJECT(o)
FROM Customer o</ejb-ql>
</query>
</entity>


And the sun-ejb-jar CustomerBean definition:


<ejb>
<ejb-name>CustomerBean</ejb-name>
<jndi-name>ejb/CustomerLocal</jndi-name>
<pass-by-reference>false</pass-by-reference>
<cmp/>
<ior-security-config>
<transport-config>
<integrity>SUPPORTED</integrity>
<confidentiality>SUPPORTED</confidentiality>
<establish-trust-in-target>SUPPORTED</establish-trust-in-target>
<establish-trust-in-client>SUPPORTED</establish-trust-in-client>
</transport-config>
<as-context>
<auth-method>USERNAME_PASSWORD</auth-method>
<realm>default</realm>
<required>false</required>
</as-context>
<sas-context>
<caller-propagation>SUPPORTED</caller-propagation>
</sas-context>
</ior-security-config>
<is-read-only-bean>false</is-read-only-bean>
<gen-classes/>
</ejb>


And the mapping definition:

<entity-mapping>
<ejb-name>CustomerBean</ejb-name>
<table-name>customer</table-name>
<cmp-field-mapping>
<field-name>login</field-name>
<column-name>customer.login</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>name</field-name>
<column-name>customer.name</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>email</field-name>
<column-name>customer.email</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>address1</field-name>
<column-name>customer.address1</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>address2</field-name>
<column-name>customer.address2</column-name>
</cmp-field-mapping>
</entity-mapping>
<entity-mapping>
<ejb-name>LocationBean</ejb-name>
<table-name>location</table-name>
<cmp-field-mapping>
<field-name>name</field-name>
<column-name>location.name</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>description</field-name>
<column-name>location.description</column-name>
</cmp-field-mapping>
<cmr-field-mapping>
<cmr-field-name>jobs</cmr-field-name>
<column-pair>
<column-name>location.name</column-name>
<column-name>job.location</column-name>
</column-pair>
<fetched-with>
<none/>
</fetched-with>
</cmr-field-mapping>
<cmr-field-mapping>
<cmr-field-name>applicants</cmr-field-name>
<column-pair>
<column-name>location.name</column-name>
<column-name>applicant.location</column-name>
</column-pair>
<fetched-with>
<none/>
</fetched-with>
</cmr-field-mapping>
</entity-mapping>

And the database definition of this table:

create table Customer(
login varchar(16),
name varchar(64),
email varchar(64),
address1 varchar(64),
address2 varchar(64));

alter table Customer
add constraint pk_customer primary key (login);

What am I doing wrong?

Thanks
[Message sent by forum member 'phill68' (phill68)]

http://forums.java.net/jive/thread.jspa?messageID=221870