A new frame to do junit test times out of the following error.
Java.lang.Exception:DEBUG STACK TRACE for Poolbackeddatasource.close (). At Com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.close (abstractpoolbackeddatasource.java:417) 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 Org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod ( disposablebeanadapter.java:208) at Org.springframework.beans.factory.support.DisposableBeanAdapter.destroy ( disposablebeanadapter.java:165) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean ( defaultsingletonbeanregistry.java:487) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton ( defaultsingletonbeanregistry.java:462) at Org.springframework.beans.factory.support.DefaultSingletonbeanregistry.destroysingletons (defaultsingletonbeanregistry.java:430) at Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:388) at Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( classpathxmlapplicationcontext.java:139) at Org.springframework.context.support.ClassPathXmlApplicationContext. <init> (classpathxmlapplicationcontext.java:83) at Junit.test.EmpTest.init (emptest.java:21) 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 Org.junit.internal.runners.ClassRoadie.runBefores (classroadie.java:49) at Org.junit.internal.runners.ClassRoadie.runProtected (classroadie.java:36) at Org.junit.internal.runners.JUnit4ClassRunner.run (junit4classrunner.java:42) at orG.eclipse.jdt.internal.junit4.runner.junit4testreference.run (junit4testreference.java:46) at Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:467) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:683) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:390) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:197)
This problem is not easy to find, Google, post pour some, said that there are sometimes such problems, sometimes not, there may be c3p0 configuration parameters, but there is no clear point of error. Had to slowly find the wrong, time spent a lot, and finally find out.
First of all to see detailed error information, add log4j.
On another test, JUnit reported the following error
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' sessionfactory ' defined in Class path resource [Com/liyi/config/applicationcontext-hibernate.xml]: Invocation of Init method failed; Nested exception is org.hibernate.MappingException:Could isn't determine type For:integer, at table:dept, for columns: [o Rg.hibernate.mapping.Column (DeptNo)] at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1338) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:473) at Org.springframework.beans.factory.support.abstractautowirecapablebeanfactory$1.run ( abstractautowirecapablebeanfactory.java:409) at Java.security.AccessController.doPrivileged (Native method) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:380) at Org.sprinGframework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:264) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:222) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:261) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:185) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:164) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:423) at Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:728) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:380) at org.springframework.context.support.classpathxmlapplicationcontext.< Init> (Classpathxmlapplicationcontext.java:139) at org.springframework.context.support.classpathxmlapplicationcontext.< Init> (classpathxmlapplicationcontext.java:83) at Junit.test.EmpTest.init (emptest.java:21) 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 Org.junit.internal.runners.ClassRoadie.runBefores (classroadie.java:49) at Org.junit.internal.runners.ClassRoadie.runProtected (classroadie.java:36) at Org.junit.internal.runners.JUnit4ClassRunner.run (junit4classrunner.java:42) at Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:46) at Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:467) at Org.eclipSe.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:683) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:390) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:197) caused by: Org.hibernate.MappingException:Could not determine type For:integer in Table:dept, for columns: [org.hibernate.mapping . Column (DeptNo)] at Org.hibernate.mapping.SimpleValue.getType (simplevalue.java:269) at Org.hibernate.cfg.configuration$1.getidentifiertype (configuration.java:2111) at Org.hibernate.type.EntityType.getIdentifierType (entitytype.java:487) at Org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType (entitytype.java:512) at Org.hibernate.type.ManyToOneType.getColumnSpan (manytoonetype.java:65) at Org.hibernate.mapping.SimpleValue.isValid (simplevalue.java:253) at Org.hibernate.mapping.ToOne.isValid ( toone.java:82) at Org.hibernate.mapping.Property.isValid (property.java:185) at org.hibernate.mapping.PersistEntclass.validate (persistentclass.java:440) at Org.hibernate.mapping.RootClass.validate (rootclass.java:192) at Org.hibernate.cfg.Configuration.validate (configuration.java:1108) at Org.hibernate.cfg.Configuration.buildSessionFactory (configuration.java:1293) at Org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory (localsessionfactorybean.java:814) At Org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory (Localsessionfactorybean.java : 732) at Org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet ( abstractsessionfactorybean.java:211) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods ( abstractautowirecapablebeanfactory.java:1369) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1335) ... More
It is obvious that the Hibernate entity mapping file is an error.
The problem with hibernate is that the type of the entity attribute, sometimes with the base type, but sometimes with the base type, should be related to the jar packages referenced in different projects.
Summary of questions:
The reason for the error in my project is the type of the entity attribute, the basic type to the object type, and the type attribute of the attribute in the mapping file.
The program can start normally, does not report the task error, the surface looks like is the C3P0 error, actually is hibernate the entity mapping error.
Just solve the problem, it posted it, hope to help you. I would be grateful if someone could help me explain the hibernate entity attributes that sometimes can't be used for basic types.