今天在启动一个web工程时,发现tomcat卡住了,但又没报错!(此时tomcat并没有启动完成)。好几次都是这样,百思不得其解,原先以为是tomcat设置的timeout时间太短,故而通过双击tomcat,在Timeouts里面将延时时间加大,但同样,启动过程中依然发现在超过新规定的timeout之后停止。如图:
后来,决定看一看控制台的日志:发现日志真的非常重要!!!最后一次卡在的地方,控制台打印的日志如下:
INFO 2015-04-27 16:03:56,500 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getPoolManager(510) Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge2jx981xc7xba18yv1y9|7582ff54, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge2jx981xc7xba18yv1y9|7582ff54, idleConnectionTestPeriod -> 7200, initialPoolSize -> 2, jdbcUrl -> jdbc:oracle:thin:@192.168.0.15:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 4, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, statementDestroyerNumActiveThreads -> -1, statementDestroyerNumConnectionsInUseAllUsers -> -1, statementDestroyerNumConnectionsInUseDefaultUser -> -1, statementDestroyerNumConnectionsWithDeferredDestroyStatementsAllUsers -> -1, statementDestroyerNumConnectionsWithDeferredDestroyStatementsDefaultUser -> -1, statementDestroyerNumDeferredDestroyStatementsAllUsers -> -1, statementDestroyerNumDeferredDestroyStatementsDefaultUser -> -1, statementDestroyerNumIdleThreads -> -1, statementDestroyerNumTasksPending -> -1, statementDestroyerNumThreads -> -1, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
通过日志表明,web工程在容器初始化的时候需要获得一个数据库的池连接,问题很有可能就出在jdbc的一些连接参数上,检查,改正,重启tomcat,问题解决!
注:在启动tomcat失败的时候,除了检查传统的配置文件,还需检查web.xml中配置了哪些会启动的servlet,很有可能某个servlet中有错,会导致项目启动失败!