hibernate JPA c3p0问题

发布于 2024-11-28 20:04:09 字数 27600 浏览 2 评论 0原文

我使用 spring、hibernage-JPA 和 c3p0 作为连接池构建 j2ee 应用程序。我已经定义了 dataSource bean:

<bean id="basicDataSource"
      class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close"
      p:driverClass="${jdbc.driverClassName}"
      p:jdbcUrl="${jdbc.url}"
      p:user="${jdbc.username}"
      p:password="${jdbc.password}"
      p:initialPoolSize="5"
      p:minPoolSize="5"
      p:maxPoolSize="10"
      p:idleConnectionTestPeriod="10"
      p:checkoutTimeout="30"
      p:maxStatements="500"
      p:acquireIncrement="0"/>

如果 spring 应用程序,我将在entityManager 中使用它。上下文:

<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      p:dataSource-ref="basicDataSource"/>

但是这种组合不起作用。这是信息日志:

2011-08-09 16:56:17,398 [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@5ae80842: startup date [Tue Aug 09 16:56:17 CEST 2011]; root of context hierarchy
2011-08-09 16:56:17,661 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]
2011-08-09 16:56:18,252 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext.xml]
2011-08-09 16:56:18,357 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/basicDataSource.xml]
2011-08-09 16:56:18,698 [main] INFO  org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/database.properties]
2011-08-09 16:56:18,793 [main] INFO  com.mchange.v2.log.MLog - MLog clients using log4j logging.
2011-08-09 16:56:18,986 [main] INFO  com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
2011-08-09 16:56:19,074 [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Bean 'basicDataSource' of type [class com.mchange.v2.c3p0.ComboPooledDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2011-08-09 16:56:19,104 [main] INFO  org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'basicPersistenceUnit'
2011-08-09 16:56:19,295 [main] INFO  org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
2011-08-09 16:56:19,302 [main] INFO  org.hibernate.cfg.Environment - Hibernate 3.6.3.Final
2011-08-09 16:56:19,304 [main] INFO  org.hibernate.cfg.Environment - hibernate.properties not found
2011-08-09 16:56:19,307 [main] INFO  org.hibernate.cfg.Environment - Bytecode provider name : javassist
2011-08-09 16:56:19,310 [main] INFO  org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
2011-08-09 16:56:19,437 [main] INFO  org.hibernate.ejb.Version - Hibernate EntityManager 3.6.3.Final
2011-08-09 16:56:19,466 [main] INFO  org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [
    name: basicPersistenceUnit
    ...]
2011-08-09 16:56:19,720 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.GpsPointEntity
2011-08-09 16:56:19,765 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.GpsPointEntity on table gps_point
2011-08-09 16:56:19,824 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.LastTripEntity
2011-08-09 16:56:19,825 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.LastTripEntity on table last_trip
2011-08-09 16:56:19,826 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.ObjectEntity
2011-08-09 16:56:19,827 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.ObjectEntity on table object
2011-08-09 16:56:19,838 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.TachoEntity
2011-08-09 16:56:19,839 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.TachoEntity on table tacho
2011-08-09 16:56:19,843 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.TachoOffsetEntity
2011-08-09 16:56:19,844 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.TachoOffsetEntity on table tacho_offset
2011-08-09 16:56:19,845 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.TripEntity
2011-08-09 16:56:19,846 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.TripEntity on table trip
2011-08-09 16:56:19,861 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.UnitEntity
2011-08-09 16:56:19,862 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.UnitEntity on table unit
2011-08-09 16:56:19,879 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.UnitEventEntity
2011-08-09 16:56:19,879 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.UnitEventEntity on table unit_event
2011-08-09 16:56:19,889 [main] INFO  org.hibernate.cfg.Configuration - Hibernate Validator not found: ignoring
2011-08-09 16:56:19,908 [main] INFO  org.hibernate.validator.util.Version - Hibernate Validator 4.2.0.Final
2011-08-09 16:56:20,434 [main] INFO  org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
2011-08-09 16:56:20,480 [main] INFO  org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
2011-08-09 16:56:20,483 [main] INFO  org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider - Using provided datasource
2011-08-09 16:56:20,545 [main] INFO  com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 0, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 30, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge0zo8h1ckgtlr18nmn36|7e94af2f, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0zo8h1ckgtlr18nmn36|7e94af2f, idleConnectionTestPeriod -> 10, initialPoolSize -> 5, jdbcUrl -> jdbc:mysql://192.168.0.123:3306/sos, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 500, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
2011-08-09 16:56:20,626 [main] WARN  org.hibernate.cfg.SettingsFactory - Could not obtain connection to query metadata
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:527)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:134)
    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:68)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:113)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2836)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2832)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at sk.wimc.t.app.Service.main(Service.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@46b29c9d -- timeout at awaitAvailable()
    at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1317)
    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
    ... 42 more
2011-08-09 16:56:20,740 [main] INFO  org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2011-08-09 16:56:20,756 [main] INFO  org.hibernate.engine.jdbc.JdbcSupportLoader - Disabling contextual LOB creation as connection was null
2011-08-09 16:56:20,757 [main] INFO  org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
2011-08-09 16:56:20,758 [main] INFO  org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2011-08-09 16:56:20,758 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
2011-08-09 16:56:20,758 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Scrollable result sets: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Connection release mode: auto
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: enabled
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Query cache: disabled
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Cache region factory : net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
2011-08-09 16:56:20,843 [main] INFO  org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: enabled
2011-08-09 16:56:20,843 [main] INFO  org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
2011-08-09 16:56:20,855 [main] INFO  org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
2011-08-09 16:56:20,863 [main] INFO  org.hibernate.cfg.SettingsFactory - Statistics: disabled
2011-08-09 16:56:20,864 [main] INFO  org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
2011-08-09 16:56:20,865 [main] INFO  org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
2011-08-09 16:56:20,865 [main] INFO  org.hibernate.cfg.SettingsFactory - Named query checking : enabled
2011-08-09 16:56:20,865 [main] INFO  org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): disabled
2011-08-09 16:56:20,903 [main] INFO  org.hibernate.impl.SessionFactoryImpl - building session factory
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_characters_clob] overrides previous : org.hibernate.type.CharacterArrayClobType@642726b2
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType@465da37c
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [characters_clob] overrides previous : org.hibernate.type.PrimitiveCharacterArrayClobType@2d9845fb
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [clob] overrides previous : org.hibernate.type.ClobType@681a791f
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Clob] overrides previous : org.hibernate.type.ClobType@681a791f
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [blob] overrides previous : org.hibernate.type.BlobType@2206179e
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Blob] overrides previous : org.hibernate.type.BlobType@2206179e
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [materialized_clob] overrides previous : org.hibernate.type.MaterializedClobType@3df89785
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_materialized_blob] overrides previous : org.hibernate.type.WrappedMaterializedBlobType@ba3bc8c
2011-08-09 16:56:20,950 [main] WARN  net.sf.ehcache.config.ConfigurationFactory - No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/Users/pierre/.m2/repository/net/sf/ehcache/ehcache-core/2.4.2/ehcache-core-2.4.2.jar!/ehcache-failsafe.xml
2011-08-09 16:56:21,681 [main] INFO  org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
2011-08-09 16:56:21,684 [main] INFO  org.hibernate.tool.hbm2ddl.SchemaValidator - Running schema validator
2011-08-09 16:56:21,684 [main] INFO  org.hibernate.tool.hbm2ddl.SchemaValidator - fetching database metadata
2011-08-09 16:56:21,765 [main] INFO  org.hibernate.tool.hbm2ddl.TableMetadata - table found: sos.gps_point
2011-08-09 16:56:21,765 [main] INFO  org.hibernate.tool.hbm2ddl.TableMetadata - columns: [gps_latitude, gps_auth_code, gps_speed, gps_origin, gps_curse, gps_longitude, gps_keyname, gps_panic, country_code, unit_serialno, gps_satellites, gps_timestamp, flag, save_timestamp, gps_bininputs, gps_ip, gps_valid, gps_point_id, gps_altitude]
2011-08-09 16:56:21,769 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@36f0b7f8: defining beans 
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at sk.wimc.t.app.Service.main(Service.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 15 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 30 more
Caused by: org.hibernate.HibernateException: Wrong column type in sos.gps_point for column country_code. Found: char, expected: varchar(2)
    at org.hibernate.mapping.Table.validateColumns(Table.java:283)
    at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1316)
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:378)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
    ... 35 more

Process finished with exit code 1

当我将数据源配置为使用 dbcp 并将其部署到 glassfish 时,它就可以工作了。但 dbcp 不适用于独立的 j2ee 应用程序。所以我尝试使用c3p0,但不成功。有人可以看到我的配置中的一些错误吗?

I build j2ee application using spring, hibernage-JPA and c3p0 for connection pool. I have defined dataSource bean:

<bean id="basicDataSource"
      class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close"
      p:driverClass="${jdbc.driverClassName}"
      p:jdbcUrl="${jdbc.url}"
      p:user="${jdbc.username}"
      p:password="${jdbc.password}"
      p:initialPoolSize="5"
      p:minPoolSize="5"
      p:maxPoolSize="10"
      p:idleConnectionTestPeriod="10"
      p:checkoutTimeout="30"
      p:maxStatements="500"
      p:acquireIncrement="0"/>

which I'm using it in entityManager if spring app. context:

<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      p:dataSource-ref="basicDataSource"/>

But this combination does't work. Here is the info log:

2011-08-09 16:56:17,398 [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@5ae80842: startup date [Tue Aug 09 16:56:17 CEST 2011]; root of context hierarchy
2011-08-09 16:56:17,661 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]
2011-08-09 16:56:18,252 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext.xml]
2011-08-09 16:56:18,357 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/basicDataSource.xml]
2011-08-09 16:56:18,698 [main] INFO  org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/database.properties]
2011-08-09 16:56:18,793 [main] INFO  com.mchange.v2.log.MLog - MLog clients using log4j logging.
2011-08-09 16:56:18,986 [main] INFO  com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
2011-08-09 16:56:19,074 [main] INFO  org.springframework.context.support.ClassPathXmlApplicationContext - Bean 'basicDataSource' of type [class com.mchange.v2.c3p0.ComboPooledDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2011-08-09 16:56:19,104 [main] INFO  org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit 'basicPersistenceUnit'
2011-08-09 16:56:19,295 [main] INFO  org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
2011-08-09 16:56:19,302 [main] INFO  org.hibernate.cfg.Environment - Hibernate 3.6.3.Final
2011-08-09 16:56:19,304 [main] INFO  org.hibernate.cfg.Environment - hibernate.properties not found
2011-08-09 16:56:19,307 [main] INFO  org.hibernate.cfg.Environment - Bytecode provider name : javassist
2011-08-09 16:56:19,310 [main] INFO  org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
2011-08-09 16:56:19,437 [main] INFO  org.hibernate.ejb.Version - Hibernate EntityManager 3.6.3.Final
2011-08-09 16:56:19,466 [main] INFO  org.hibernate.ejb.Ejb3Configuration - Processing PersistenceUnitInfo [
    name: basicPersistenceUnit
    ...]
2011-08-09 16:56:19,720 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.GpsPointEntity
2011-08-09 16:56:19,765 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.GpsPointEntity on table gps_point
2011-08-09 16:56:19,824 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.LastTripEntity
2011-08-09 16:56:19,825 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.LastTripEntity on table last_trip
2011-08-09 16:56:19,826 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.ObjectEntity
2011-08-09 16:56:19,827 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.ObjectEntity on table object
2011-08-09 16:56:19,838 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.TachoEntity
2011-08-09 16:56:19,839 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.TachoEntity on table tacho
2011-08-09 16:56:19,843 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.TachoOffsetEntity
2011-08-09 16:56:19,844 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.TachoOffsetEntity on table tacho_offset
2011-08-09 16:56:19,845 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.TripEntity
2011-08-09 16:56:19,846 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.TripEntity on table trip
2011-08-09 16:56:19,861 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.UnitEntity
2011-08-09 16:56:19,862 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.UnitEntity on table unit
2011-08-09 16:56:19,879 [main] INFO  org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: sk.wimc.t.domain.UnitEventEntity
2011-08-09 16:56:19,879 [main] INFO  org.hibernate.cfg.annotations.EntityBinder - Bind entity sk.wimc.t.domain.UnitEventEntity on table unit_event
2011-08-09 16:56:19,889 [main] INFO  org.hibernate.cfg.Configuration - Hibernate Validator not found: ignoring
2011-08-09 16:56:19,908 [main] INFO  org.hibernate.validator.util.Version - Hibernate Validator 4.2.0.Final
2011-08-09 16:56:20,434 [main] INFO  org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
2011-08-09 16:56:20,480 [main] INFO  org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
2011-08-09 16:56:20,483 [main] INFO  org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider - Using provided datasource
2011-08-09 16:56:20,545 [main] INFO  com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 0, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 30, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge0zo8h1ckgtlr18nmn36|7e94af2f, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0zo8h1ckgtlr18nmn36|7e94af2f, idleConnectionTestPeriod -> 10, initialPoolSize -> 5, jdbcUrl -> jdbc:mysql://192.168.0.123:3306/sos, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 500, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
2011-08-09 16:56:20,626 [main] WARN  org.hibernate.cfg.SettingsFactory - Could not obtain connection to query metadata
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:527)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:134)
    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:68)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:113)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2836)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2832)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at sk.wimc.t.app.Service.main(Service.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@46b29c9d -- timeout at awaitAvailable()
    at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1317)
    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
    ... 42 more
2011-08-09 16:56:20,740 [main] INFO  org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2011-08-09 16:56:20,756 [main] INFO  org.hibernate.engine.jdbc.JdbcSupportLoader - Disabling contextual LOB creation as connection was null
2011-08-09 16:56:20,757 [main] INFO  org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
2011-08-09 16:56:20,758 [main] INFO  org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2011-08-09 16:56:20,758 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
2011-08-09 16:56:20,758 [main] INFO  org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Scrollable result sets: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Connection release mode: auto
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
2011-08-09 16:56:20,759 [main] INFO  org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: enabled
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Query cache: disabled
2011-08-09 16:56:20,761 [main] INFO  org.hibernate.cfg.SettingsFactory - Cache region factory : net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory
2011-08-09 16:56:20,843 [main] INFO  org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: enabled
2011-08-09 16:56:20,843 [main] INFO  org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
2011-08-09 16:56:20,855 [main] INFO  org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
2011-08-09 16:56:20,863 [main] INFO  org.hibernate.cfg.SettingsFactory - Statistics: disabled
2011-08-09 16:56:20,864 [main] INFO  org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
2011-08-09 16:56:20,865 [main] INFO  org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
2011-08-09 16:56:20,865 [main] INFO  org.hibernate.cfg.SettingsFactory - Named query checking : enabled
2011-08-09 16:56:20,865 [main] INFO  org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): disabled
2011-08-09 16:56:20,903 [main] INFO  org.hibernate.impl.SessionFactoryImpl - building session factory
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_characters_clob] overrides previous : org.hibernate.type.CharacterArrayClobType@642726b2
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType@465da37c
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [characters_clob] overrides previous : org.hibernate.type.PrimitiveCharacterArrayClobType@2d9845fb
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [clob] overrides previous : org.hibernate.type.ClobType@681a791f
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Clob] overrides previous : org.hibernate.type.ClobType@681a791f
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [blob] overrides previous : org.hibernate.type.BlobType@2206179e
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [java.sql.Blob] overrides previous : org.hibernate.type.BlobType@2206179e
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [materialized_clob] overrides previous : org.hibernate.type.MaterializedClobType@3df89785
2011-08-09 16:56:20,916 [main] INFO  org.hibernate.type.BasicTypeRegistry - Type registration [wrapper_materialized_blob] overrides previous : org.hibernate.type.WrappedMaterializedBlobType@ba3bc8c
2011-08-09 16:56:20,950 [main] WARN  net.sf.ehcache.config.ConfigurationFactory - No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/Users/pierre/.m2/repository/net/sf/ehcache/ehcache-core/2.4.2/ehcache-core-2.4.2.jar!/ehcache-failsafe.xml
2011-08-09 16:56:21,681 [main] INFO  org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
2011-08-09 16:56:21,684 [main] INFO  org.hibernate.tool.hbm2ddl.SchemaValidator - Running schema validator
2011-08-09 16:56:21,684 [main] INFO  org.hibernate.tool.hbm2ddl.SchemaValidator - fetching database metadata
2011-08-09 16:56:21,765 [main] INFO  org.hibernate.tool.hbm2ddl.TableMetadata - table found: sos.gps_point
2011-08-09 16:56:21,765 [main] INFO  org.hibernate.tool.hbm2ddl.TableMetadata - columns: [gps_latitude, gps_auth_code, gps_speed, gps_origin, gps_curse, gps_longitude, gps_keyname, gps_panic, country_code, unit_serialno, gps_satellites, gps_timestamp, flag, save_timestamp, gps_bininputs, gps_ip, gps_valid, gps_point_id, gps_altitude]
2011-08-09 16:56:21,769 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@36f0b7f8: defining beans 
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at sk.wimc.t.app.Service.main(Service.java:17)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/Users/pierre/Documents/workspace/ideaProjects/tServer/app/target/classes/META-INF/spring/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
    at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
    at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 15 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 30 more
Caused by: org.hibernate.HibernateException: Wrong column type in sos.gps_point for column country_code. Found: char, expected: varchar(2)
    at org.hibernate.mapping.Table.validateColumns(Table.java:283)
    at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1316)
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:378)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
    ... 35 more

Process finished with exit code 1

When I configure the dataSource to using dbcp and deploy it to glassfish, then it's work. But dbcp does't work for stand alone j2ee app. So I try to using c3p0, but unsuccessful. Can someone see some error(s) in my config?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷了相思 2024-12-05 20:04:09

好的,我解决了这个问题,它是在 enetity 的类型定义中,我添加了这个参数:columnDefinition =“char”到列注释中。

Ok, I solved this problem it was in type definition in enetity, I add this param: columnDefinition = "char" to column annotation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文