Re: Connection pool race condition
Fixed this by setting the service to startup delayed sc config service_name start= delayed-auto Thanks Chris
RE: Connection pool race condition
From: cjder...@gmail.com [mailto:cjder...@gmail.com] On Behalf Of chris derham Subject: Re: Connection pool race condition Fixed this by setting the service to startup delayed sc config service_name start= delayed-auto Sounds like a FAQ/Wiki entry might be in order here, but I'm not quite sure where... - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Connection pool race condition
You could use Windows' service dependency management ( http://support.microsoft.com/kb/193888) to start Tomcat only after Oracle reports that it's running. This might still cause problems if Oracle does the same as SQL Server and continues recovering after its official startup has finished. In that case, I'd try to write a small service that polled Oracle every few seconds till it started, then reported itself as started, and make Tomcat dependent on that. Service creation in Windows isn't too hard, but it's another moving part to support! - Peter On 27 April 2011 21:18, chris derham ch...@derham.me.uk wrote: All, So we have various tomcat services setup on windows. When windows updates are auto installed, sometimes they force a reboot of the server. When this happens, the tomcats win the race with the database (Oracle) to startup. Then the connection pool can't start, and then the war file is flagged as shutdown. We have tried to make the tomcat services dependent on the oracle service (both db service and tns listener), but same happens. Just tried to turn the connection pool initial size down to zero, but the app fetches some config at startup. I guess we could recode to lazily fetch this upon first access. Just curious if anyone has hit this, and if there is a way to delay the tomcat service startup. Tomcat 7.0.12 Windows server 2008 r2 64 bit java -version java version 1.6.0_24 Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) We have connection pool setup in catalina_base\conf\context.xml Resource name=jdbc/xts auth=Container type=javax.sql.DataSource username=username password=password driverClassName=oracle.jdbc.OracleDriver url=jdbc:oracle:thin:@localhost:1521:xe maxActive=20 maxIdle=2 minIdle=1 initialSize=2 / 27-Apr-2011 19:48:22 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext 27-Apr-2011 19:48:31 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Destroying Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Shutting down log4j 27-Apr-2011 20:25:36 org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class liquibase.integration.servlet.LiquibaseServletListener java.lang.RuntimeException: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at liquibase.integration.servlet.LiquibaseServletListener.contextInitialized(LiquibaseServletListener.java:159) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at org.apache.naming.NamingContext.lookup(NamingContext.java:843) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:159) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:392) Thanks Chris
Re: Connection pool race condition
On 4/28/2011 8:36 AM, Peter Crowther wrote: You could use Windows' service dependency management ( http://support.microsoft.com/kb/193888) to start Tomcat only after Oracle reports that it's running. This might still cause problems if Oracle does the same as SQL Server and continues recovering after its official startup has finished. In that case, I'd try to write a small service that polled Oracle every few seconds till it started, then reported itself as started, and make Tomcat dependent on that. Service creation in Windows isn't too hard, but it's another moving part to support! Is there something the app can do to reset the pool once it starts? If so, what about a ServletcontextListener that tests the oracle connection at startup, and doesn't allow it to continue until it's ready? Or is that just not possible? - Peter On 27 April 2011 21:18, chris derhamch...@derham.me.uk wrote: All, So we have various tomcat services setup on windows. When windows updates are auto installed, sometimes they force a reboot of the server. When this happens, the tomcats win the race with the database (Oracle) to startup. Then the connection pool can't start, and then the war file is flagged as shutdown. We have tried to make the tomcat services dependent on the oracle service (both db service and tns listener), but same happens. Just tried to turn the connection pool initial size down to zero, but the app fetches some config at startup. I guess we could recode to lazily fetch this upon first access. Just curious if anyone has hit this, and if there is a way to delay the tomcat service startup. Tomcat 7.0.12 Windows server 2008 r2 64 bit java -version java version 1.6.0_24 Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) We have connection pool setup in catalina_base\conf\context.xml Resource name=jdbc/xts auth=Container type=javax.sql.DataSource username=username password=password driverClassName=oracle.jdbc.OracleDriver url=jdbc:oracle:thin:@localhost:1521:xe maxActive=20 maxIdle=2 minIdle=1 initialSize=2 / 27-Apr-2011 19:48:22 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext 27-Apr-2011 19:48:31 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Destroying Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Shutting down log4j 27-Apr-2011 20:25:36 org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class liquibase.integration.servlet.LiquibaseServletListener java.lang.RuntimeException: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at liquibase.integration.servlet.LiquibaseServletListener.contextInitialized(LiquibaseServletListener.java:159) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at org.apache.naming.NamingContext.lookup(NamingContext.java:843) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:159) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:392) Thanks Chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail:
Re: Connection pool race condition
this is the way to go, just setup a service dependency On 4/28/2011 7:36 AM, Peter Crowther wrote: You could use Windows' service dependency management ( http://support.microsoft.com/kb/193888) to start Tomcat only after Oracle reports that it's running. This might still cause problems if Oracle does the same as SQL Server and continues recovering after its official startup has finished. In that case, I'd try to write a small service that polled Oracle every few seconds till it started, then reported itself as started, and make Tomcat dependent on that. Service creation in Windows isn't too hard, but it's another moving part to support! - Peter On 27 April 2011 21:18, chris derhamch...@derham.me.uk wrote: All, So we have various tomcat services setup on windows. When windows updates are auto installed, sometimes they force a reboot of the server. When this happens, the tomcats win the race with the database (Oracle) to startup. Then the connection pool can't start, and then the war file is flagged as shutdown. We have tried to make the tomcat services dependent on the oracle service (both db service and tns listener), but same happens. Just tried to turn the connection pool initial size down to zero, but the app fetches some config at startup. I guess we could recode to lazily fetch this upon first access. Just curious if anyone has hit this, and if there is a way to delay the tomcat service startup. Tomcat 7.0.12 Windows server 2008 r2 64 bit java -version java version 1.6.0_24 Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) We have connection pool setup in catalina_base\conf\context.xml Resource name=jdbc/xts auth=Container type=javax.sql.DataSource username=username password=password driverClassName=oracle.jdbc.OracleDriver url=jdbc:oracle:thin:@localhost:1521:xe maxActive=20 maxIdle=2 minIdle=1 initialSize=2 / 27-Apr-2011 19:48:22 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext 27-Apr-2011 19:48:31 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Destroying Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Shutting down log4j 27-Apr-2011 20:25:36 org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class liquibase.integration.servlet.LiquibaseServletListener java.lang.RuntimeException: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at liquibase.integration.servlet.LiquibaseServletListener.contextInitialized(LiquibaseServletListener.java:159) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at org.apache.naming.NamingContext.lookup(NamingContext.java:843) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:159) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:392) Thanks Chris - No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1209 / Virus Database: 1500/3601 - Release Date: 04/27/11 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Connection pool race condition
There is another solution that should work, and that is to define initialSize=0 so that no attempt is made to contact the DB when it is created. Then set testOnBorrow=true The jdbc-pool project should work like this http://people.apache.org/~fhanik/jdbc-pool/ Filip On 4/28/2011 1:58 PM, Filip Hanik - Dev Lists wrote: this is the way to go, just setup a service dependency On 4/28/2011 7:36 AM, Peter Crowther wrote: You could use Windows' service dependency management ( http://support.microsoft.com/kb/193888) to start Tomcat only after Oracle reports that it's running. This might still cause problems if Oracle does the same as SQL Server and continues recovering after its official startup has finished. In that case, I'd try to write a small service that polled Oracle every few seconds till it started, then reported itself as started, and make Tomcat dependent on that. Service creation in Windows isn't too hard, but it's another moving part to support! - Peter On 27 April 2011 21:18, chris derhamch...@derham.me.uk wrote: All, So we have various tomcat services setup on windows. When windows updates are auto installed, sometimes they force a reboot of the server. When this happens, the tomcats win the race with the database (Oracle) to startup. Then the connection pool can't start, and then the war file is flagged as shutdown. We have tried to make the tomcat services dependent on the oracle service (both db service and tns listener), but same happens. Just tried to turn the connection pool initial size down to zero, but the app fetches some config at startup. I guess we could recode to lazily fetch this upon first access. Just curious if anyone has hit this, and if there is a way to delay the tomcat service startup. Tomcat 7.0.12 Windows server 2008 r2 64 bit java -version java version 1.6.0_24 Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) We have connection pool setup in catalina_base\conf\context.xml Resource name=jdbc/xts auth=Container type=javax.sql.DataSource username=username password=password driverClassName=oracle.jdbc.OracleDriver url=jdbc:oracle:thin:@localhost:1521:xe maxActive=20 maxIdle=2 minIdle=1 initialSize=2 / 27-Apr-2011 19:48:22 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext 27-Apr-2011 19:48:31 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Destroying Spring FrameworkServlet 'dispatcher' 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext 27-Apr-2011 20:21:22 org.apache.catalina.core.ApplicationContext log INFO: Shutting down log4j 27-Apr-2011 20:25:36 org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class liquibase.integration.servlet.LiquibaseServletListener java.lang.RuntimeException: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at liquibase.integration.servlet.LiquibaseServletListener.contextInitialized(LiquibaseServletListener.java:159) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: javax.naming.NamingException: Cannot create PoolableConnectionFactory (ORA-01033: ORACLE initialization or shutdown in progress ) at org.apache.naming.NamingContext.lookup(NamingContext.java:843) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:145) at org.apache.naming.NamingContext.lookup(NamingContext.java:814) at org.apache.naming.NamingContext.lookup(NamingContext.java:159) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158) at javax.naming.InitialContext.lookup(InitialContext.java:392) Thanks Chris - No virus found in this message. Checked by AVG -