Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 26608 invoked from network); 8 Jun 2009 14:26:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Jun 2009 14:26:26 -0000 Received: (qmail 45845 invoked by uid 500); 8 Jun 2009 14:26:37 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 45780 invoked by uid 500); 8 Jun 2009 14:26:37 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 45770 invoked by uid 99); 8 Jun 2009 14:26:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2009 14:26:37 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of michael.d.dick@gmail.com designates 209.85.220.222 as permitted sender) Received: from [209.85.220.222] (HELO mail-fx0-f222.google.com) (209.85.220.222) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2009 14:26:26 +0000 Received: by fxm22 with SMTP id 22so3123337fxm.9 for ; Mon, 08 Jun 2009 07:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=Y8yTfGCFaFGSnuy0hweplDqOh2BRHztu64j3Ic3FUzQ=; b=jh1idkUDZY9X1rcddrltfCMWyi5bGP/iA+0hCBtifOGXtUfd8XCCTYKP+InpiEcvK5 G9C1cxGL6swW8KCsyKgDUQrg8SGD6HG6fYJaEto7QFZsJWi87T73zRjsNADndKYOAyt3 ohCkOY1xSJq6Nw+PhrwXK93WspfU6fjUBSSkk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=el8J75PR37DoL/E1wVmxX/kY7uHsv/Ueds0gwhISgL3qHuQze5HBnV8smBH2My/132 UhASRRHK6i2qyrmVJDQ/Ku86h4ArKeCyQUL+1l6oHSBlIFrlG7uqmE+2eKndB0dJ1lWS /wx2XbaMscemgKpQ/JXpjILMMPAAiR9uSC10E= MIME-Version: 1.0 Received: by 10.223.115.80 with SMTP id h16mr4147782faq.94.1244471165630; Mon, 08 Jun 2009 07:26:05 -0700 (PDT) In-Reply-To: References: <72c1350f0906050656p77391880g6d5ca1bb6642cde8@mail.gmail.com> Date: Mon, 8 Jun 2009 09:26:05 -0500 Message-ID: <72c1350f0906080726l3752eb92t6bf77c0685e37f4f@mail.gmail.com> Subject: Re: OpenJPA reconnect derby database issue. From: Michael Dick To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=001636c5b352c2bf55046bd70564 X-Virus-Checked: Checked by ClamAV on apache.org --001636c5b352c2bf55046bd70564 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Yu Wang, I'm not sure how to configure Spring to not cache the EntityManager. My guess is that Spring would cache an EntityManager for the lifetime of a transaction and then close it at the end of the tran. The best reference I could find is here [1]. Using an entirely new EntityManagerFactory should also resolve the problem (that will result in a new EntityManager and a new connection to the database). Another thing to look into is the openjpa.ConnectionRetainMode property [2]. You should have this set to "transaction" or "on-demand" to make sure the EntityManager isn't caching a connection to Derby. [1] http://static.springframework.org/spring/docs/2.5.x/reference/orm.html [2] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_dbsetup_retain Hope this helps, -mike On Mon, Jun 8, 2009 at 12:22 AM, wang yu wrote: > Hi Mike, > Following is how I close cache: > > > > value="false" /> > value="false" /> > > Your concern is spring cache the EntityManager, right? How can I avoid > this? Should I use a brand new entityManagerFactory? > > Regards, > Yu Wang > > > On Fri, Jun 5, 2009 at 9:56 PM, Michael Dick > wrote: > > Hi Yu Wang, > > > > It sounds like someone is maintaining a pool of EntityManagers. The > > assertOpen method isn't checking Derby, it's concerned with the state of > the > > EntityManager itself. > > > > How did you close the cache of OpenJPA EntityManagers? I have very little > > experience with Spring, but the stack makes it look like it's handing out > > the EntityManager that is being used. > > > > -mike > > > > On Fri, Jun 5, 2009 at 2:44 AM, wang yu wrote: > > > >> Hello, > >> My application uses Tomcat6,derby,spring and OpenJPA 1.20. > >> My case is stopping derby database and restarting it. And I found even > >> if I catch the database connection broken exception and create an new > >> EntityManager successfully after derby restarts, the following > >> exception stack will be printed : > >> > >> <2009-06-05 15:22:21,140> > >> >> at which the context was closed is available if Runtime=TRACE logging > >> is enabled.@agent > >> > (key=Domain7:machine0:0,machine0;jsessionid=0F915CC5A079F150E6C1E34661661831)> > >> > >> org.apache.openjpa.persistence.InvalidStateException: The context has > >> been closed. The stack trace at which the context was closed is > >> available if Runtime=TRACE logging is enabled. > >> at > >> org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4367) > >> at > >> > org.apache.openjpa.kernel.BrokerImpl.beginOperation(BrokerImpl.java:1766) > >> at > >> org.apache.openjpa.kernel.BrokerImpl.newQuery(BrokerImpl.java:3483) > >> at > >> > org.apache.openjpa.kernel.DelegatingBroker.newQuery(DelegatingBroker.java:1225) > >> at > >> > org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:870) > >> at > >> > org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:865) > >> at > >> > org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:77) > >> at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source) > >> at > >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > >> at java.lang.reflect.Method.invoke(Method.java:585) > >> at > >> > org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:357) > >> at $Proxy15.createQuery(Unknown Source) > >> at > >> com.***.dao.JPAImpl.CallpathDaoImpl.findByName(CallpathDaoImpl.java:31) > >> at > >> com.***.dao.JPAImpl.CallpathDaoImpl.findByName(CallpathDaoImpl.java:18) > >> at com.***.ds.Persister.persist(Persister.java:139) > >> at com.***.ds.PersistRunner.run(PersistRunner.java:44) > >> at > >> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417) > >> at > >> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269) > >> at java.util.concurrent.FutureTask.run(FutureTask.java:123) > >> at > >> > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:65) > >> at > >> > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:168) > >> at > >> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) > >> at > >> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) > >> at java.lang.Thread.run(Thread.java:595) > >> > >> And I ensure the new EntityManager connect derby successfully by > >> netstat -an|grep 1527. > >> I closed all cache of OpenJPA but same error still happen. > >> > >> > >> Regards, > >> Yu Wang > >> > > > --001636c5b352c2bf55046bd70564--