openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heiko <it-media.k...@daimler.com>
Subject EntityNotFoundException caused by EntityManager.refresh()
Date Wed, 14 Apr 2010 13:11:02 GMT

Hello,

in our Webservice-Application we use application managed persistence by
implementing entity managers via ThreadLocal to ensure there exists only a
single EntityManager at one time.

We have an Entity that is retrieved from the Database via em.find(). This
entity contains a OneToMany() relationship to a list of address objects,
with cascade set to REFRESH and fetch set lazy. Right after the find() is
done, a refresh() is issued on the object to make sure, it reflects the
actual state of the object in the database.

We now have the following problem. 

In case the base entity is request and the list of addresses is obtained
everything works fine. However, if externally by other systems accessing the
database, an address entry is deleted, and a subsequent call to the entity
is done, OpenJPA fails with the following exception:

&lt;openjpa-1.3.0-SNAPSHOT-r422266:831336 nonfatal store error&gt;
org.apache.openjpa.persistence.EntityNotFoundException: Diese Operation ist
für einige Instanzen fehlgeschlagen. Suchen Sie in den verschachtelten
Ausnahmen nach Einzelheiten.&#13;
	at
org.apache.openjpa.kernel.BrokerImpl.throwNestedExceptions(BrokerImpl.java:2356)&#13;
	at
org.apache.openjpa.kernel.BrokerImpl.refreshInternal(BrokerImpl.java:2885)&#13;
	at org.apache.openjpa.kernel.BrokerImpl.refresh(BrokerImpl.java:2778)&#13;
	at
org.apache.openjpa.kernel.DelegatingBroker.refresh(DelegatingBroker.java:1078)&#13;
	at
org.apache.openjpa.persistence.EntityManagerImpl.refresh(EntityManagerImpl.java:688)&#13;
	at
com.mbbank.pas.webservice.services.GetPersonHandler.handleGetPerson(GetPersonHandler.java:2965)&#13;
	at
net.corpds.emea.services.partner._64.wsdl.PartnerAccessServiceSoapBindingImpl.getPerson(PartnerAccessServiceSoapBindingImpl.java:105)&#13;
	at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)&#13;
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&#13;
	at java.lang.reflect.Method.invoke(Method.java:618)&#13;
	at
org.apache.axis2.jaxws.server.dispatcher.JavaDispatcher.invokeTargetOperation(JavaDispatcher.java:70)&#13;
	at
org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.invoke(JavaBeanDispatcher.java:97)&#13;
	at
org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:100)&#13;
	at
org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:142)&#13;
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:375)&#13;
	at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:305)&#13;
	at
com.ibm.ws.websvcs.transport.http.WASAxis2Servlet.doPost(WASAxis2Servlet.java:921)&#13;
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)&#13;
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)&#13;
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)&#13;
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:593)&#13;
	at
com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:534)&#13;
	at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)&#13;
	at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:751)&#13;
	at
com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)&#13;
	at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:126)&#13;
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)&#13;
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)&#13;
	at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)&#13;
	at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)&#13;
	at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)&#13;
	at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)&#13;
	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)&#13;
	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)&#13;
	at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)&#13;
	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)&#13;
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)&#13;

The German error message corresponds to the following error code in the
English version I guess.

The instance of type "{0}" with oid "{1}" 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.

The exception occurs at the line we call em.refresh() and seems to occur,
because the address object currently managed by the EntityManager does no
longer exist in the database. However, I would have assumed 'refresh'()
simply corrects the entities and removes the no-longer-existing object from
the database. Why does it throw an exception and what am I supposed to
change resp. do? How can I simply refresh the base object and all its
related relationships to make sure they reflect the correct state of the
tables?

If you need further information do not hesitate and ask. I hope I could
explain the problem.

Best regards,

Heiko
-- 
View this message in context: http://n2.nabble.com/EntityNotFoundException-caused-by-EntityManager-refresh-tp4901557p4901557.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message