openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Givanildo Dantas Alves <mrg...@ig.com.br>
Subject Intermittent EntityNotFoundException for loading of ID field
Date Mon, 28 Oct 2013 12:59:15 GMT
Hi, 

In my current model, a ConcreteRecord might be associated to N AliasRecord
instances. The relationship is bidirectional: ManyToOne specified in
AliasRecord class and OneToMany specified in ConcreteRecord. 

I am testing a concurrent scenario where each thread creates a new
AliasRecord and a new ConcreteRecord instances: 

1. AliasRecord newAlias = <NEW ALIAS INSTANCE>
2. entityManager.persist(newAlias); 
3. ConcreteRecord newConcreteRecord = <NEW CONCRETE RECORD INSTANCE (WITH ID
ASSIGNED BY APP CODE)>
4. <LINK ALIAS TO CONCRETE RECORD>
5. entityManager.persist(newResource); 
6. newAlias.updateTimeStamp(); 
7. newAlias = entityManager.merge(newAlias); 
8. <POST PROCESSING OF ALIAS AND CONCRETE RECORD INSTANCES>

However, now and then I get the an error when getting the ID value for the
ConcreteRecord instance: 

<openjpa-2.2.1.1-SNAPSHOT-r422266:1438134 nonfatal store error>
org.apache.openjpa.persistence.EntityNotFoundException: The instance of type
"class com.test.testapp.model.ConcreteRecord" with oid "null" no longer
exists in the data store.  This may mean that you deleted the instance in a
separate transaction, but this context still has a cached version. 
FailedObject: com.test.testapp.model.ConcreteRecord@268fae22 
        at
org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:3119) 
        at
org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:3195) 
        at
org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1658) 
        at
org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1591) 
        at
com.test.testapp.model.ConcreteRecord.pcGetrecordId(ConcreteRecord.java) 
        at
com.test.testapp.model.ConcreteRecord.getRecordId(ConcreteRecord.java:167) 
        at com.test.testapp.model.AliasRecord.toString(AliasRecord.java:479) 
        at com.test.testapp.aspects.log.Logging.getArguments(Logging.aj:363) 
        at
com.test.testapp.aspects.log.Logging.ajc$before$com_test_testapp_aspects_log_Logging$3$a001ed84(Logging.aj:253)

        at
com.test.testapp.persistence.ReconciliationManager.doReconciliationForNewAlias(ReconciliationManager.java:180)

        at
com.test.testapp.persistence.AliasManager.doCreateAlias(AliasManager.java:345) 
        at
com.test.testapp.persistence.AliasManager.createAlias(AliasManager.java:105) 
        at
com.test.testapp.web.AliasService.createAliasRecord_aroundBody2(AliasService.java:334) 
        at
com.test.testapp.web.AliasService.createAliasRecord_aroundBody3$advice(AliasService.java:62)

        at
com.test.testapp.web.AliasService.createAliasRecord(AliasService.java:1) 
        at
com.test.testapp.web.AliasService.createAliasRecord_aroundBody0(AliasService.java:227) 
        at
com.test.testapp.web.AliasService.createAliasRecord_aroundBody1$advice(AliasService.java:93)

        at
com.test.testapp.web.AliasService.createAliasRecord(AliasService.java:201) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76) 
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:602) 
        at
org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63)



According to the logs, it seems OpenJPA attempted to load from the database
a record with null ID 

[10/15/13 17:31:09:234 BRT] 00000054 OpenJPA       3   openjpa.jdbc.SQLDiag:
Trace: load: class com.test.testapp.model.ConcreteRecord oid: null 
[10/15/13 17:31:09:234 BRT] 00000054 OpenJPA       3   openjpa.jdbc.SQL:
Trace: <t 492874511, conn -517931784> executing prepstmnt -1427080773 SELECT
t0.RECORD_ID FROM CONCRETE_RECORD t0 WHERE t0.RECORD_ID IS NULL 

That is odd, knowing that the ConcreteRecord instance had its ID value
assigned prior to the EntityManager.persist(...) call and each thread
operates with different records and does no deletion 

My environment: 
- WebSphere 8.5.0.2 
- OpenJPA 2.2.1.1 snapshot version bundled with WebSphere 
- IBM JDK 7 build pwa6470sr1ifix-20120419_02(SR1+IV19490+IV19661) 

The problem also happens with Apache OpenJPA 2.2.2 release and the latest
OpenJPA 2.3.0 nightly build. 

For JDK 7, I could also reproduce the problem with IBM JDK SR4_FP2 release. 

The curious part is that the problem does not happen with IBM JDK 6. 

Has anyone stumble upon a similar issue ? Any tip on how to troubleshoot the
problem is also welcome 

I'm still not sure whether the root cause is in my application code, in
OpenJPA itself or even in JDK


Thanks



--
View this message in context: http://openjpa.208410.n2.nabble.com/Intermittent-EntityNotFoundException-for-loading-of-ID-field-tp7585392.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Mime
View raw message