You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Tomcat Programmer <tc...@yahoo.com> on 2012/04/24 22:19:04 UTC

No Connection Exception

Hello, 

I'm running into a problem where I suddenly get "No Connection Exception" errors in my application.  This appears to happen after a period of inactivity, though it is difficult to assess exactly how much inactivity time has transpired because the application is only very lightly used. It is a web application, using Tomcat 7 as the web container, with a container managed collection pool.  If I simply restart tomcat, the exact same SQL statement would then complete with no problems.  When this occurs, the nested exception in the stack trace looks like this: 

Caused by: java.sql.SQLNonTransientConnectionException: No current connection.
         at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor331.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:600)
         at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
         at $Proxy13.prepareStatement(Unknown Source)
         at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1474)
         at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1423)
         at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:697)
         at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:585)
         ... 77 more
Caused by: org.apache.derby.client.am.SqlException: No current connection.
         at org.apache.derby.client.am.Connection.checkForClosedConnection(Unknown Source)
         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
         ... 87 more

The only way to clear this up seems to be restarting the web container.   Is there some setting in Derby which is causing these connections to go stale?  Is there any way to trace this and find out the cause? 

Thanks in advance, 
Tom

Re: No Connection Exception

Posted by Tomcat Programmer <tc...@yahoo.com>.
Its been awhile, but this issue is still a problem for me. I set these options in the email below, but this doesn't seem to provide any insight into why it happens.  There doesn't seem to be any pattern to the problem that I can see. At first it was once every few weeks.  Then it disappeared for almost three months. Now it happened two days in a row back to back, even on the same day.  Here is an example from the derby log showing the startup, and then it starting itself automatically.  


Any insight would be greatly appreciated.  Thank you all in advance. 





Fri Aug 17 09:57:01 EDT 2012:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.8.2.2 - (1181258): instance 8fe3828d-0139-2a88-6ac3-00005d2d3fe2
on database directory /usr/local/derby10/databases/PPRD  with class loader sun.misc.Launcher$AppClassLoader@2d252d25
Loaded from file:/usr/local/derby10/lib/derby.jar
java.vendor=IBM Corporation
java.runtime.version=pxi3260sr8-20100409_01 (SR8)
java.fullversion=JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr8-20100401_55940 (JIT enabled, AOT enabled)
J9VM - 20100401_055940
JIT  - r9_20100401_15339
GC   - 20100308_AA
user.dir=/usr/local/derby10/databases
derby.system.home=/usr/local/derby10/databases
java.lang.Throwable: boot trace
        at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
        at org.apache.derby.impl.store.raw.RawStore.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
        at org.apache.derby.impl.store.access.RAMAccessManager.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
        at org.apache.derby.impl.db.BasicDatabase.bootStore(Unknown Source)
        at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source)
        at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
Database Class Loader started - derby.database.classpath=''
----------------------------------------------------------------
Fri Aug 17 17:07:53 EDT 2012:
Shutting down instance 8fe3828d-0139-2a88-6ac3-00005d2d3fe2 on database directory /usr/local/derby10/databases/PPRD with class loader sun.misc.Launcher$AppClassLoader@2d252d25
java.lang.Throwable: shutdown trace
        at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.stop(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.stop(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.shutdown(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.shutdown(Unknown Source)
        at org.apache.derby.impl.db.DatabaseContextImpl.cleanupOnError(Unknown Source)
        at org.apache.derby.iapi.services.context.ContextManager.cleanupOnError(Unknown Source)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.cleanupOnError(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source)
        at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
Fri Aug 17 17:07:53 EDT 2012 Thread[DRDAConnThread_32,5,main] (DATABASE = PPRD), (DRDAID = {64}), Database 'PPRD' shutdown.
----------------------------------------------------------------
Mon Aug 20 09:59:00 EDT 2012:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.8.2.2 - (1181258): instance 5927c366-0139-2a88-6ac3-00005d2d3fe2
on database directory /usr/local/derby10/databases/PPRD  with class loader sun.misc.Launcher$AppClassLoader@2d252d25
Loaded from file:/usr/local/derby10/lib/derby.jar
java.vendor=IBM Corporation
java.runtime.version=pxi3260sr8-20100409_01 (SR8)
java.fullversion=JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr8-20100401_55940 (JIT enabled, AOT enabled)
J9VM - 20100401_055940
JIT  - r9_20100401_15339
GC   - 20100308_AA
user.dir=/usr/local/derby10/databases
derby.system.home=/usr/local/derby10/databases
java.lang.Throwable: boot trace
        at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
        at org.apache.derby.impl.store.raw.RawStore.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
        at org.apache.derby.impl.store.access.RAMAccessManager.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
        at org.apache.derby.impl.db.BasicDatabase.bootStore(Unknown Source)
        at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
        at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown Source)
        at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown Source)
        at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.EmbeddedDriver.connect(Unknown Source)
        at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
        at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
Database Class Loader started - derby.database.classpath=''





________________________________
 From: Katherine Marsden <km...@sbcglobal.net>
To: Derby Discussion <de...@db.apache.org> 
Sent: Wednesday, April 25, 2012 1:06 PM
Subject: Re: No Connection Exception
 
On 4/25/2012 5:31 AM, Rick Hillegas wrote:
> On 4/24/12 6:49 PM, Tomcat Programmer wrote:
>> That is a very good question... there is no error message at all.  However, what I did see was a startup message, like when the database initially starts. Except, I never restarted it!  And the machine did not reboot... are there ever conditions where it auto-restarts itself?
> Derby engines and databases don't spontaneously reboot as far as I know. This suggests that the engine and/or database are being bounced by code higher up your application stack.
> 
You might want to set the following derby properties as system properties or in a derby.properties file in derby.system.home to help figure out the history and where the restart occurs.

derby.infolog.append=true
derby.stream.error.logBootTrace=true

Re: No Connection Exception

Posted by Katherine Marsden <km...@sbcglobal.net>.
On 4/25/2012 5:31 AM, Rick Hillegas wrote:
> On 4/24/12 6:49 PM, Tomcat Programmer wrote:
>> That is a very good question... there is no error message at all.  
>> However, what I did see was a startup message, like when the database 
>> initially starts. Except, I never restarted it!  And the machine did 
>> not reboot... are there ever conditions where it auto-restarts itself?
> Derby engines and databases don't spontaneously reboot as far as I 
> know. This suggests that the engine and/or database are being bounced 
> by code higher up your application stack.
>
You might want to set the following derby properties as system 
properties or in a derby.properties file in derby.system.home to help 
figure out the history and where the restart occurs.

derby.infolog.append=true
derby.stream.error.logBootTrace=true




Re: No Connection Exception

Posted by Tomcat Programmer <tc...@yahoo.com>.
>
> Derby engines and databases don't spontaneously reboot as far as I know. 

> This suggests that the engine and/or database are being bounced by code 

> higher up your application stack.

>


Thanks Rick. I  certainly assume that they wouldn't normally do that. I was thinking maybe there was a specific trigger situation that might cause it. I'm not sure what else could be in the software stack to cause this. The derby version is 10.8.something (whatever was the most recent as of about a month ago) and its started in Network mode listening only to localhost address.  The Apache Tomcat 7 web container is on the same host, with a container-managed connection pool, using the built-in Tomcat connection pool classes.  On top of that is eclipselink JPA 2.0.  Certainly none of that is something that I would expect to restart the database.  The application doesn't have any code written directly against the database, everything goes through JPA.






________________________________
 From: Rick Hillegas <ri...@oracle.com>
To: derby-user@db.apache.org 
Sent: Wednesday, April 25, 2012 8:31 AM
Subject: Re: No Connection Exception
 
On 4/24/12 6:49 PM, Tomcat Programmer wrote:
> That is a very good question... there is no error message at all.  However, what I did see was a startup message, like when the database initially starts. Except, I never restarted it!  And the machine did not reboot... are there ever conditions where it auto-restarts itself?

Hope this helps,
-Rick
> 
> 
> ------------------------------------------------------------------------
> *From:* Katherine Marsden <km...@sbcglobal.net>
> *To:* Derby Discussion <de...@db.apache.org>
> *Sent:* Tuesday, April 24, 2012 5:06 PM
> *Subject:* Re: No Connection Exception
> 
> On 4/24/2012 1:19 PM, Tomcat Programmer wrote:
>> Hello,
>> 
>> 
>> 
>> The only way to clear this up seems to be restarting the web container.   Is there some setting in Derby which is causing these connections to go stale?  Is there any way to
>> trace this and find out the cause?
>> 
> Is there an interesting error in the derby.log that might indicate when you lost the connection?
> 
> 
> 

RE: No Connection Exception

Posted by "Bergquist, Brett" <BB...@canoga.com>.
I believe if there is a severe condition that Derby detects, it will internally restart and output to the log the startup message again.  If you don't have the derby.log setting to append it will appear as if the complete engine restarted.  If you do have it to append, you might see the severe error that caused the internal restart.

I think it is DRDAConnection.c where this can be seen but I don't have the code in front of me at this moment.

-----Original Message-----
From: Rick Hillegas [mailto:rick.hillegas@oracle.com] 
Sent: Wednesday, April 25, 2012 8:32 AM
To: derby-user@db.apache.org
Subject: Re: No Connection Exception

On 4/24/12 6:49 PM, Tomcat Programmer wrote:
> That is a very good question... there is no error message at all.  
> However, what I did see was a startup message, like when the database 
> initially starts. Except, I never restarted it!  And the machine did 
> not reboot... are there ever conditions where it auto-restarts itself?
Derby engines and databases don't spontaneously reboot as far as I know. 
This suggests that the engine and/or database are being bounced by code higher up your application stack.

Hope this helps,
-Rick
>
>
> ----------------------------------------------------------------------
> --
> *From:* Katherine Marsden <km...@sbcglobal.net>
> *To:* Derby Discussion <de...@db.apache.org>
> *Sent:* Tuesday, April 24, 2012 5:06 PM
> *Subject:* Re: No Connection Exception
>
> On 4/24/2012 1:19 PM, Tomcat Programmer wrote:
>> Hello,
>>
>>
>>
>> The only way to clear this up seems to be restarting the web 
>> container.   Is there some setting in Derby which is causing these 
>> connections to go stale?  Is there any way to trace this and find out 
>> the cause?
>>
> Is there an interesting error in the derby.log that might indicate 
> when you lost the connection?
>
>
>




Re: No Connection Exception

Posted by Rick Hillegas <ri...@oracle.com>.
On 4/24/12 6:49 PM, Tomcat Programmer wrote:
> That is a very good question... there is no error message at all.  
> However, what I did see was a startup message, like when the database 
> initially starts. Except, I never restarted it!  And the machine did 
> not reboot... are there ever conditions where it auto-restarts itself?
Derby engines and databases don't spontaneously reboot as far as I know. 
This suggests that the engine and/or database are being bounced by code 
higher up your application stack.

Hope this helps,
-Rick
>
>
> ------------------------------------------------------------------------
> *From:* Katherine Marsden <km...@sbcglobal.net>
> *To:* Derby Discussion <de...@db.apache.org>
> *Sent:* Tuesday, April 24, 2012 5:06 PM
> *Subject:* Re: No Connection Exception
>
> On 4/24/2012 1:19 PM, Tomcat Programmer wrote:
>> Hello,
>>
>>
>>
>> The only way to clear this up seems to be restarting the web 
>> container.   Is there some setting in Derby which is causing these 
>> connections to go stale?  Is there any way to
>> trace this and find out the cause?
>>
> Is there an interesting error in the derby.log that might indicate 
> when you lost the connection?
>
>
>


Re: No Connection Exception

Posted by Tomcat Programmer <tc...@yahoo.com>.
That is a very good question... there is no error message at all.  However, what I did see was a startup message, like when the database initially starts. Except, I never restarted it!  And the machine did not reboot... are there ever conditions where it auto-restarts itself?  




________________________________
 From: Katherine Marsden <km...@sbcglobal.net>
To: Derby Discussion <de...@db.apache.org> 
Sent: Tuesday, April 24, 2012 5:06 PM
Subject: Re: No Connection Exception
 

On 4/24/2012 1:19 PM, Tomcat Programmer wrote: 
Hello, 
>
>
>
>The only way to clear this up seems to be restarting the
              web container.   Is there some setting in Derby which is
              causing these connections to go stale?  Is there any way
              to 
trace this and find out the cause? 
>
>
Is there an interesting error in the derby.log that might indicate when you lost the connection?

Re: No Connection Exception

Posted by Katherine Marsden <km...@sbcglobal.net>.
On 4/24/2012 1:19 PM, Tomcat Programmer wrote:
> Hello,
>
>
>
> The only way to clear this up seems to be restarting the web 
> container.   Is there some setting in Derby which is causing these 
> connections to go stale?  Is there any way to
> trace this and find out the cause?
>
Is there an interesting error in the derby.log that might indicate when 
you lost the connection?