org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session

报错信息如下:

org.springframework.transaction.CannotCreateTransactionException: 
Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
	at org.springframework.orm.hibernate5.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:542)
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:377)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:461)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
	at com.sun.proxy.$Proxy39.getQuestionByNo(Unknown Source)
	at com.evaluationmanager.test.TypeTest.test(TypeTest.java:19)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:109)
	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:136)
	at org.hibernate.internal.SessionImpl.connection(SessionImpl.java:524)
	at org.springframework.orm.hibernate5.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:448)
	... 37 more
	
	at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:692)
	at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
	at org.hibernate.c3p0.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:73)
	at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:35)
	at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:106)
	... 40 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
	at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1469)
	at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)
	at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:554)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:758)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:685)
	... 44 more
Caused by: java.sql.SQLException: No suitable driver
	at java.sql.DriverManager.getDriver(DriverManager.java:315)
	at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:285)
	at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
	at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:202)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
	at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
	at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
	at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
	at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

我的配置配置:

db.properties

#data
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/evaluationmanager?characterEncoding=utf8
jdbc.username=root
jdbc.password=flzx3qc

# c3p0
c3p0.minPoolSize=3
c3p0.maxPoolSize=50
c3p0.initialPoolSize=5
c3p0.maxIdleTime=120
c3p0.acquireIncrement=5
c3p0.idleConnectionTestPeriod=60

# hibernate
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=update
hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
hibernate.connection.autocommit=true
hibernate.javax.persistence.validation.mode=none
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider

applicationContext-hibernate.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans 
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xmlns:aop="http://www.springframework.org/schema/aop"
	
	xsi:schemaLocation="http://www.springframework.org/schema/beans        
 	             http://www.springframework.org/schema/beans/spring-beans.xsd
 	       		 http://www.springframework.org/schema/context        		 
 	             http://www.springframework.org/schema/context/spring-context.xsd
 	       		 http://www.springframework.org/schema/tx 
 	       		 http://www.springframework.org/schema/tx/spring-tx.xsd
 	       		 http://www.springframework.org/schema/aop 
 	       		 http://www.springframework.org/schema/aop/spring-aop.xsd">  
 	       		 
            <!-- default-autowire="byName" default-lazy-init="false"> -->
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:db/*.properties</value>
			</list>
		</property>
	</bean>
	<!-- c3p0数据源 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="${jdbc.driverClassName}"/>  
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>  
        <property name="password" value="${jdbc.password}"/>
        <property name="minPoolSize" value="${c3p0.minPoolSize}"/>  
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}"/>  
        <property name="initialPoolSize" value="${c3p0.initialPoolSize}"/>  
        <property name="maxIdleTime" value="${c3p0.maxIdleTime}"/>  
        <property name="acquireIncrement" value="${c3p0.acquireIncrement}"/>  
        
        <property name="idleConnectionTestPeriod" value="${c3p0.idleConnectionTestPeriod}"/>  
	</bean>
	<!-- 配置sessionFactory -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
				<prop key="hiberate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
				<prop key="hibernate.connection.autocommit">${hibernate.connection.autocommit}</prop>
				<prop key="hiberate.javax.persistence.validation.mode">${hibernate.javax.persistence.validation.mode}</prop>
				
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
			</props>
		</property>
		<!-- 扫描实体类包 -->
		<property name="packagesToScan" value="com.evaluationmanager.entiy"></property>
	</bean>
	
	<!-- 配置hibernatTemplate 模板 -->
	 <bean id="hibernatTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
	 	<property name="sessionFactory" ref="sessionFactory"></property>
	 </bean>
	 <!-- 配置事务管理 --> 
	 <!-- transationManager -->
	 <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
	 	<property name="sessionFactory" ref="sessionFactory"></property>
	 </bean>
	 <!-- 开启事务注解 -->
	 <tx:annotation-driven transaction-manager="transactionManager"/>
 </beans>

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans 
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xmlns:aop="http://www.springframework.org/schema/aop"
	
	xsi:schemaLocation="http://www.springframework.org/schema/beans        
 	             http://www.springframework.org/schema/beans/spring-beans.xsd
 	       		 http://www.springframework.org/schema/context        		 
 	             http://www.springframework.org/schema/context/spring-context.xsd
 	       		 http://www.springframework.org/schema/tx 
 	       		 http://www.springframework.org/schema/tx/spring-tx.xsd
 	       		 http://www.springframework.org/schema/aop 
 	       		 http://www.springframework.org/schema/aop/spring-aop.xsd">  
 	       		 
            <!-- default-autowire="byName" default-lazy-init="false"> -->
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:db/*.properties</value>
			</list>
		</property>
	</bean>
	<!-- c3p0数据源 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="${jdbc.driverClassName}"/>  
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>  
        <property name="password" value="${jdbc.password}"/>
        <property name="minPoolSize" value="${c3p0.minPoolSize}"/>  
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}"/>  
        <property name="initialPoolSize" value="${c3p0.initialPoolSize}"/>  
        <property name="maxIdleTime" value="${c3p0.maxIdleTime}"/>  
        <property name="acquireIncrement" value="${c3p0.acquireIncrement}"/>  
        
        <property name="idleConnectionTestPeriod" value="${c3p0.idleConnectionTestPeriod}"/>  
	</bean>
	<!-- 配置sessionFactory -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
				<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
				<prop key="hiberate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
				<prop key="hibernate.connection.autocommit">${hibernate.connection.autocommit}</prop>
				<prop key="hiberate.javax.persistence.validation.mode">${hibernate.javax.persistence.validation.mode}</prop>
				
				<prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
			</props>
		</property>
		<!-- 扫描实体类包 -->
		<property name="packagesToScan" value="com.evaluationmanager.entiy"></property>
	</bean>
	
	<!-- 配置hibernatTemplate 模板 -->
	 <bean id="hibernatTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
	 	<property name="sessionFactory" ref="sessionFactory"></property>
	 </bean>
	 <!-- 配置事务管理 --> 
	 <!-- transationManager -->
	 <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
	 	<property name="sessionFactory" ref="sessionFactory"></property>
	 </bean>
	 <!-- 开启事务注解 -->
	 <tx:annotation-driven transaction-manager="transactionManager"/>
 </beans>

解决分析:

项目之前没有配置c3p0连接池,sessionFactory配置的信息如上所示,之后加了c3p0之后,启动tomcat需要30多秒,启动不报错。

八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.SetAllPropertiesRule begin
警告: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'Encoding' to 'UTF-8' did not find a matching property.
八月 12, 2018 2:20:55 上午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:evaluationmanager' did not find a matching property.
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/7.0.82
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Sep 29 2017 12:23:15 UTC
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         7.0.82.0
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 10
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            10.0
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             C:\Program Files\Java\jdk1.8.0_66\jre
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.8.0_66-b17
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         D:\Program Files\eclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         D:\java-tool\apache-tomcat-7.0.82
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:51275
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\Program Files\eclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\java-tool\apache-tomcat-7.0.82
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\Program Files\eclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\java-tool\apache-tomcat-7.0.82\endorsed
八月 12, 2018 2:20:55 上午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
八月 12, 2018 2:20:55 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_66\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.8.0_66/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_66/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_66/bin/../jre/lib/amd64;C:\Program Files\Java\jdk1.8.0_66\bin;C:\Program Files\Java\jdk1.8.0_66\jre\bin;C:\Program Files\Common Files\Autodesk Shared\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;D:\mysql\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;D:\study software\mysql\bin;D:\study software\mysql5.5\bin;D:\study software\mysql5_5\bin;D:\MyPath;D:\Program Files\MySQL\MySQL Server 5.5\bin;d:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;d:\Program Files\Microsoft SQL Server\100\Tools\Binn\;d:\Program Files\Microsoft SQL Server\100\DTS\Binn\;d:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;d:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Program Files\mysql-5.7.21-winx64\bin;D:\Program Files\oracle;D:\java-tool\apache-maven-3.5.3\bin;D:\Program Files\Git\cmd;D:\Program Files\Git\bin;D:\Program Files\TortoiseSVN\bin;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;;D:\study-software\Java\eclipse-jee-neon-2-win32-x86_64 (2)\eclipse;;.
八月 12, 2018 2:20:56 上午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
八月 12, 2018 2:20:56 上午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
八月 12, 2018 2:20:56 上午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 872 ms
八月 12, 2018 2:20:56 上午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
八月 12, 2018 2:20:56 上午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.82
八月 12, 2018 2:20:56 上午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
警告: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [181] milliseconds.
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TaglibUriRule body
信息: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
八月 12, 2018 2:20:58 上午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
八月 12, 2018 2:20:58 上午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
八月 12, 2018 2:20:58 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
八月 12, 2018 2:21:33 上午 org.apache.catalina.core.ApplicationContext log
信息: Set web app root system property: 'webapp.root' = [D:\Program Files\eclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\evaluationmanager\]
八月 12, 2018 2:21:33 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing log4j from [classpath:log4j.properties]
八月 12, 2018 2:21:34 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
八月 12, 2018 2:21:34 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
八月 12, 2018 2:21:34 上午 org.apache.catalina.startup.Catalina start
信息: Server startup in 38717 ms

但是一访问页面,加载数据库数据需要很长时间,获取不到数据库数据。并且报错:

Connections could not be acquired from the underlying database!

后来经过半天折腾,将下图红色框内的配置删除之后,一切正常。可能是c3p0配置与下图的配置冲突吧,导致程序不加载,配置文件的配置信息,最终导致连接不上数据库。

 

 

阅读更多

Could not open Hibernate Session for transaction

09-07

各位大侠:rn 小弟用的是服务器weblogic,数据库oracle。现在碰到的问题是如果20个用户并发就OK.但是如果50个服务器就会报错,报错信息如下:rn <[weblogic.servlet.irnnternal.WebAppServletContext@1f61bcf - appName: 'webroot', name: 'webroot', contrnext-path: '/ses'] Servlet failed with Exceptionrnorg.springframework.transaction.CannotCreateTransactionException: Could not openrn Hibernate Session for transaction; nested exception is org.hibernate.exception.rnGenericJDBCException: Cannot open connectionrn at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegirnn(HibernateTransactionManager.java:538)rn at org.springframework.transaction.support.AbstractPlatformTransactionMarnnager.getTransaction(AbstractPlatformTransactionManager.java:350)rn at org.springframework.transaction.interceptor.TransactionAspectSupport.rncreateTransactionIfNecessary(TransactionAspectSupport.java:262)rn at org.springframework.transaction.interceptor.TransactionInterceptor.inrnvoke(TransactionInterceptor.java:102)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(rnReflectiveMethodInvocation.java:166)rn Truncated. see log file for complete stacktracernorg.hibernate.exception.GenericJDBCException: Cannot open connectionrn at org.hibernate.exception.SQLStateConverter.handledNonSpecificExceptionrn(SQLStateConverter.java:91)rn at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.jrnava:79)rn at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelprner.java:43)rn at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelprner.java:29)rn at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManagerrn.java:363)rn Truncated. see log file for complete stacktracernjava.sql.SQLException: We are already in the process of making 11 connections anrnd the number of simultaneous builds has been throttled to 10rn at org.logicalcobwebs.proxool.Prototyper.checkSimultaneousBuildThrottle(rnPrototyper.java:260)rn at org.logicalcobwebs.proxool.ConnectionPool.getConnection(ConnectionPoornl.java:170)rn at org.logicalcobwebs.proxool.ProxoolDataSource.getConnection(ProxoolDatrnaSource.java:97)rn at org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource.rngetConnection(AbstractRoutingDataSource.java:133)rn at com.dongyun.ses.web.DynamicDataSource.getConnection(DynamicDataSourcern.java:57)rn Truncated. see log file for complete stacktracern>rn

Could not open Hibernate Session ; nested exception is java.lang.NullPointerExce

10-14

[code=java]HTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.NullPointerExceptionrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn org.codehaus.enunciate.modules.spring_app.HTTPRequestContextFilter.doFilter(HTTPRequestContextFilter.java:36)rnrnrnroot cause rnrnorg.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.NullPointerExceptionrn org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:545)rn org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:283)rn org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:234)rn org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:93)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)rn $Proxy54.list(Unknown Source)rn org.apache.jsp.frame_jsp._jspService(frame_jsp.java:94)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn org.codehaus.enunciate.modules.spring_app.HTTPRequestContextFilter.doFilter(HTTPRequestContextFilter.java:36)rnrnrnroot cause rnrnjava.lang.NullPointerExceptionrn org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)rn org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:526)rn org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:535)rn sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn java.lang.reflect.Method.invoke(Method.java:597)rn org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.java:1124)rn $Proxy47.openSession(Unknown Source)rn org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:445)rn org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:283)rn org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:234)rn org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:93)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)rn org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)rn $Proxy54.list(Unknown Source)rn org.apache.jsp.frame_jsp._jspService(frame_jsp.java:94)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn org.codehaus.enunciate.modules.spring_app.HTTPRequestContextFilter.doFilter(HTTPRequestContextFilter.java:36)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.rnrnrn--------------------------------------------------------------------------------rnrnApache Tomcat/6.0.20[/code]

没有更多推荐了,返回首页