Announcement Announcement Module
Collapse
No announcement yet.
SingleConnectionDataSource configuration problem ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SingleConnectionDataSource configuration problem ?

    Hi,

    I would like to report a configuration problem that seems strange to me.
    My project is based on Struts + Spring + Hibernate + MySql.
    In order to run Unit tests, I use a special application context configuration file that defines a dataSource of type SingleConnectionDataSource.

    Here's the application context configuration file I'm using (in blue the interesting part) :

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <!-- ========================= PERSISTENCE DEFINITIONS ========================= -->

    <!-- data source definition -->
    <bean id="myDataSource" class="org.springframework.jdbc.datasource.SingleC onnectionDataSource" destroy-method="close">
    <property name="driverClassName">
    <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
    <value>jdbc:mysql://localhost:3306/Zorglux</value>
    </property>
    <property name="username">
    <value>u_Zorglux</value>
    </property>
    <property name="password">
    <value>zogzogzog</value>
    </property>
    </bean>

    <!-- Hibernate session factory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="mappingResources">
    <list>
    <value>zorglux/objetsmetiers/attribut/Attribute.hbm.xml</value>
    <value>zorglux/objetsmetiers/attribut/CaracteristiquesRank.hbm.xml</value>
    <value>zorglux/objetsmetiers/inominax/Token.hbm.xml</value>
    <value>zorglux/objetsmetiers/inominax/TokenSet.hbm.xml</value>
    <value>zorglux/objetsmetiers/personnage/classe/Classe.hbm.xml</value>
    <value>zorglux/objetsmetiers/personnage/level/XPLevelProgression.hbm.xml</value>
    <value>zorglux/objetsmetiers/personnage/race/Race.hbm.xml</value>
    <value>zorglux/objetsmetiers/rules/Rule.hbm.xml</value>
    <value>zorglux/objetsmetiers/rules/Ajustement.hbm.xml</value>
    <value>zorglux/objetsmetiers/rules/GroupOfAjustements.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.cglib.use_reflection_optimizer">fal se</prop>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.M ySQLDialect</prop>
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.use_outer_join">true</prop>
    <prop key="hibernate.transaction.factory_class">net.sf.h ibernate.transaction.JDBCTransactionFactory</prop>
    </props>
    </property>
    <property name="dataSource">
    <ref local="myDataSource"/>
    </property>
    </bean>

    <!-- Hibernate Interceptor -->
    <bean id="myHibernateInterceptor" class="org.springframework.orm.hibernate.Hibernate Interceptor">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    <bean id="myTransactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    <bean id="myTransactionInterceptor" class="org.springframework.transaction.interceptor .TransactionInterceptor">
    <property name="transactionManager">
    <ref bean="myTransactionManager"/>
    </property>
    <property name="transactionAttributeSource">
    <value>
    zorglux.dao.implementation.ClasseDAOImpl.*=PROPAGA TION_REQUIRED
    zorglux.dao.implementation.DAOImpl.*=PROPAGATION_R EQUIRED
    zorglux.dao.implementation.RaceDAOImpl.*=PROPAGATI ON_REQUIRED
    zorglux.dao.implementation.TokenSetDAOImpl.*=PROPA GATION_REQUIRED
    </value>
    </property>
    </bean>


    <!-- ========================= DAO ========================= -->

    <bean id="myDAOTarget" class="zorglux.dao.implementation.DAOImpl">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    <bean id="myDAO" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>zorglux.dao.DAO</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>myTransactionInterceptor</value>
    <value>myHibernateInterceptor</value>
    <value>myDAOTarget</value>
    </list>
    </property>
    </bean>

    <bean id="myTokenSetDAOTarget" class="zorglux.dao.implementation.TokenSetDAOImpl" >
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    <bean id="myTokenSetDAO" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>zorglux.dao.TokenSetDAO</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>myTransactionInterceptor</value>
    <value>myHibernateInterceptor</value>
    <value>myTokenSetDAOTarget</value>
    </list>
    </property>
    </bean>

    <bean id="myRaceDAOTarget" class="zorglux.dao.implementation.RaceDAOImpl">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    <bean id="myRaceDAO" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>zorglux.dao.RaceDAO</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>myTransactionInterceptor</value>
    <value>myHibernateInterceptor</value>
    <value>myRaceDAOTarget</value>
    </list>
    </property>
    </bean>

    <bean id="myClasseDAOTarget" class="zorglux.dao.implementation.ClasseDAOImpl">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    <bean id="myClasseDAO" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>zorglux.dao.ClasseDAO</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>myTransactionInterceptor</value>
    <value>myHibernateInterceptor</value>
    <value>myClasseDAOTarget</value>
    </list>
    </property>
    </bean>

    <!-- ========================= BUSINESS DEFINITIONS ========================= -->

    </beans>

    When I run my unit test, I have the following exception :

    INFO [factory.xml.XmlBeanDefinitionReader:loadBeanDefini tions] - Loading XML bean definitions from class path resource [applicationContextForUnitTests.xml]
    INFO [context.support.ClassPathXmlApplicationContext:ref reshBeanFactory] - Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=6609937]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [myDataSource,sessionFactory,myHibernateInterceptor ,myTransactionManager,myTransactionInterceptor,myD AOTarget,myDAO,myTokenSetDAOTarget,myTokenSetDAO,m yRaceDAOTarget,myRaceDAO,myClasseDAOTarget,myClass eDAO]; Root of BeanFactory hierarchy
    INFO [context.support.ClassPathXmlApplicationContext:ref resh] - 13 beans defined in ApplicationContext [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=6609937]
    INFO [context.support.ClassPathXmlApplicationContext:ini tMessageSource] - No MessageSource found for [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=6609937]: using empty StaticMessageSource
    INFO [context.support.ClassPathXmlApplicationContext:ref reshListeners] - Refreshing listeners
    INFO [factory.support.DefaultListableBeanFactoryreInstantiateSingletons] - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [myDataSource,sessionFactory,myHibernateInterceptor ,myTransactionManager,myTransactionInterceptor,myD AOTarget,myDAO,myTokenSetDAOTarget,myTokenSetDAO,m yRaceDAOTarget,myRaceDAO,myClasseDAOTarget,myClass eDAO]; Root of BeanFactory hierarchy]
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myDataSource'
    INFO [jdbc.datasource.SingleConnectionDataSource:setDriv erClassName] - Loaded JDBC driver: com.mysql.jdbc.Driver
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'sessionFactory'
    INFO [hibernate.cfg.Environment:<clinit>] - Hibernate 2.1.6
    INFO [hibernate.cfg.Environment:<clinit>] - loaded properties from resource hibernate.properties: {hibernate.connection.username=u_Zorglux, hibernate.connection.password=zogzogzog, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.MySQLDi alect, hibernate.connection.url=jdbc:mysql:/localhost:3306/Zorglux, hibernate.connection.driver_class=org.gjt.mm.mysql .Driver}
    INFO [hibernate.cfg.Environment:<clinit>] - using CGLIB reflection optimizer
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.attribut.Attribute -> attribut
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.attribut.CaracteristiquesRan k -> CARACTERISTIQUES_RANK
    INFO [hibernate.cfg.Binder:bindCollection] - Mapping collection: zorglux.objetsmetiers.attribut.CaracteristiquesRan k.ranks -> RANKS
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.inominax.Token -> TOKEN
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.inominax.TokenSet -> TOKEN_SET
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.personnage.classe.Classe -> CLASSE
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.personnage.level.XPLevelProg ression -> XP_LEVEL_PROGRESSION
    INFO [hibernate.cfg.Binder:bindSubclass] - Mapping subclass: zorglux.objetsmetiers.personnage.level.Mathematica lXPLevelProgression -> XP_LEVEL_PROGRESSION
    INFO [hibernate.cfg.Binder:bindSubclass] - Mapping subclass: zorglux.objetsmetiers.personnage.level.UserDefined XPLevelProgression -> XP_LEVEL_PROGRESSION
    INFO [hibernate.cfg.Binder:bindCollection] - Mapping collection: zorglux.objetsmetiers.personnage.level.UserDefined XPLevelProgression.allXPLevel -> XP_LEVEL_VALUES
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.personnage.race.Race -> RACE
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.rules.Rule -> RULE
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.rules.Ajustement -> AJUSTEMENT
    INFO [hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.rules.GroupOfAjustements -> ADJUSTMENTS_GROUP
    INFO [orm.hibernate.LocalSessionFactoryBean:afterPropert iesSet] - Building new Hibernate SessionFactory
    INFO [hibernate.cfg.Configuration:secondPassCompile] - processing one-to-many association mappings
    INFO [hibernate.cfg.Binder:bindCollectionSecondPass] - Mapping collection: zorglux.objetsmetiers.inominax.TokenSet.setOfToken s -> TOKEN
    INFO [hibernate.cfg.Binder:bindCollectionSecondPass] - Mapping collection: zorglux.objetsmetiers.rules.GroupOfAjustements.aju stements -> AJUSTEMENT
    INFO [hibernate.cfg.Configuration:secondPassCompile] - processing one-to-one association property references
    INFO [hibernate.cfg.Configuration:secondPassCompile] - processing foreign key constraints
    INFO [hibernate.dialect.Dialect:<init>] - Using dialect: net.sf.hibernate.dialect.MySQLDialect
    INFO [hibernate.cfg.SettingsFactory:buildSettings] - Maximim outer join fetch depth: 2
    INFO [hibernate.cfg.SettingsFactory:buildSettings] - Use outer join fetching: true
    INFO [hibernate.connection.ConnectionProviderFactory:new ConnectionProvider] - Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceC onnectionProvider
    INFO [hibernate.transaction.TransactionFactoryFactory:bu ildTransactionFactory] - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactor y
    INFO [hibernate.transaction.TransactionManagerLookupFact ory:getTransactionManagerLookup] - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    INFO [jdbc.datasource.SingleConnectionDataSource:getConn ectionFromDriverManager] - Creating new JDBC connection to [jdbc:mysql://localhost:3306/Zorglux]
    INFO [hibernate.cfg.SettingsFactory:buildSettings] - Use scrollable result sets: true
    INFO [hibernate.cfg.SettingsFactory:buildSettings] - Use JDBC3 getGeneratedKeys(): true
    INFO [hibernate.cfg.SettingsFactory:buildSettings] - Optimize cache for minimal puts: false
    INFO [hibernate.cfg.SettingsFactory:buildSettings] - Query language substitutions: {}
    INFO [hibernate.cfg.SettingsFactory:buildSettings] - cache provider: net.sf.hibernate.cache.EhCacheProvider
    INFO [hibernate.cfg.Configuration:configureCaches] - instantiating and configuring caches
    INFO [hibernate.impl.SessionFactoryImpl:<init>] - building session factory
    INFO [hibernate.util.ReflectHelper:getBulkBean] - reflection optimizer disabled for: zorglux.objetsmetiers.inominax.TokenSet, BulkBeanException: Property is private (property setSetOfTokens)
    INFO [hibernate.util.ReflectHelper:getBulkBean] - reflection optimizer disabled for: zorglux.objetsmetiers.rules.GroupOfAjustements, BulkBeanException: Property is private (property setAjustements)
    INFO [hibernate.impl.SessionFactoryObjectFactory:addInst ance] - Not binding factory to JNDI, no JNDI name configured
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myHibernateInterceptor'
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myTransactionManager'
    INFO [orm.hibernate.HibernateTransactionManager:afterPro pertiesSet] - Using DataSource [org.springframework.jdbc.datasource.SingleConnecti onDataSource@9a8a68] from Hibernate SessionFactory for HibernateTransactionManager
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myTransactionInterceptor'
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.RaceDAOImpl.delete(zorg lux.objetsmetiers.personnage.race.Race)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.RaceDAOImpl.saveOrUpdat e(zorglux.objetsmetiers.personnage.race.Race)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public zorglux.objetsmetiers.personnage.race.Race zorglux.dao.implementation.RaceDAOImpl.loadRace(ja va.lang.Long)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public java.lang.String[] zorglux.dao.implementation.RaceDAOImpl.getRacesNam e()] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public zorglux.objetsmetiers.personnage.race.Race zorglux.dao.implementation.RaceDAOImpl.findRaceByN ame(java.lang.String)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.ClasseDAOImpl.delete(zo rglux.objetsmetiers.personnage.classe.Classe)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.ClasseDAOImpl.saveOrUpd ate(zorglux.objetsmetiers.personnage.classe.Classe )] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public zorglux.objetsmetiers.personnage.classe.Classe zorglux.dao.implementation.ClasseDAOImpl.loadClass e(java.lang.Long)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public java.lang.String[] zorglux.dao.implementation.ClasseDAOImpl.getClasse sName()] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public zorglux.objetsmetiers.personnage.classe.Classe zorglux.dao.implementation.ClasseDAOImpl.findClass eByName(java.lang.String)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.TokenSetDAOImpl.delete( zorglux.objetsmetiers.inominax.TokenSet)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.TokenSetDAOImpl.saveOrU pdate(zorglux.objetsmetiers.inominax.TokenSet)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public zorglux.objetsmetiers.inominax.TokenSet zorglux.dao.implementation.TokenSetDAOImpl.findTok enSetById(java.lang.Long)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public zorglux.objetsmetiers.inominax.TokenSet zorglux.dao.implementation.TokenSetDAOImpl.findTok enSetByName(java.lang.String)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public java.util.List zorglux.dao.implementation.TokenSetDAOImpl.getAllT okenSet()] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public java.lang.String[] zorglux.dao.implementation.TokenSetDAOImpl.getToke nSetNames()] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.DAOImpl.delete(zorglux. objetsmetiers.PersistentClass)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public zorglux.objetsmetiers.PersistentClass zorglux.dao.implementation.DAOImpl.loadPersistentC lass(java.lang.Class,java.lang.Long)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public net.sf.hibernate.SessionFactory zorglux.dao.implementation.DAOImpl.getSessionFacto ry()] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public net.sf.hibernate.Session zorglux.dao.implementation.DAOImpl.getSession()] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.DAOImpl.setSessionFacto ry(net.sf.hibernate.SessionFactory)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [private boolean zorglux.dao.implementation.DAOImpl.isClassPersiste nt(java.lang.Class)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [public void zorglux.dao.implementation.DAOImpl.saveOrUpdate(zo rglux.objetsmetiers.PersistentClass)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [transaction.interceptor.MethodMapTransactionAttrib uteSource:addTransactionalMethod] - Adding transactional method [protected java.lang.Object zorglux.dao.implementation.DAOImpl.uniqueResultOrN ull(java.util.List)] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myDAOTarget'
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myDAO'
    INFO [aop.framework.ProxyFactoryBean:setBeanFactory] - ProxyFactoryBean config: org.springframework.aop.framework.ProxyFactoryBean : 1 interfaces=[interface zorglux.dao.DAO]; 2 pointcuts=[DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.transaction.interceptor.Transa ctionInterceptor@c3c315],DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.orm.hibernate.HibernateInterce ptor@1dec1dd]]; targetSource=[Singleton target source (not dynamic): target=[zorglux.dao.implementation.DAOImpl@aa233f]]; advisorChainFactory=org.springframework.aop.framew ork.HashMapCachingAdvisorChainFactory@458f41expose Proxy=false; frozen=false; enableCglibSubclassOptimizations=false; aopProxyFactory=org.springframework.aop.framework. DefaultAopProxyFactory@c01e99;
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myTokenSetDAOTarget'
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myTokenSetDAO'
    INFO [aop.framework.ProxyFactoryBean:setBeanFactory] - ProxyFactoryBean config: org.springframework.aop.framework.ProxyFactoryBean : 1 interfaces=[interface zorglux.dao.TokenSetDAO]; 2 pointcuts=[DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.transaction.interceptor.Transa ctionInterceptor@c3c315],DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.orm.hibernate.HibernateInterce ptor@1dec1dd]]; targetSource=[Singleton target source (not dynamic): target=[zorglux.dao.implementation.TokenSetDAOImpl@1d88db7]]; advisorChainFactory=org.springframework.aop.framew ork.HashMapCachingAdvisorChainFactory@402af3expose Proxy=false; frozen=false; enableCglibSubclassOptimizations=false; aopProxyFactory=org.springframework.aop.framework. DefaultAopProxyFactory@c3e9e9;
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myRaceDAOTarget'
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myRaceDAO'
    INFO [aop.framework.ProxyFactoryBean:setBeanFactory] - ProxyFactoryBean config: org.springframework.aop.framework.ProxyFactoryBean : 1 interfaces=[interface zorglux.dao.RaceDAO]; 2 pointcuts=[DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.transaction.interceptor.Transa ctionInterceptor@c3c315],DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.orm.hibernate.HibernateInterce ptor@1dec1dd]]; targetSource=[Singleton target source (not dynamic): target=[zorglux.dao.implementation.RaceDAOImpl@1ba94d]]; advisorChainFactory=org.springframework.aop.framew ork.HashMapCachingAdvisorChainFactory@82751exposeP roxy=false; frozen=false; enableCglibSubclassOptimizations=false; aopProxyFactory=org.springframework.aop.framework. DefaultAopProxyFactory@14d5bc9;
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myClasseDAOTarget'
    INFO [factory.support.DefaultListableBeanFactory:getBean] - Creating shared instance of singleton bean 'myClasseDAO'
    INFO [aop.framework.ProxyFactoryBean:setBeanFactory] - ProxyFactoryBean config: org.springframework.aop.framework.ProxyFactoryBean : 1 interfaces=[interface zorglux.dao.ClasseDAO]; 2 pointcuts=[DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.transaction.interceptor.Transa ctionInterceptor@c3c315],DefaultPointcutAdvisor: pointcut=[Pointcut.TRUE] advice=[org.springframework.orm.hibernate.HibernateInterce ptor@1dec1dd]]; targetSource=[Singleton target source (not dynamic): target=[zorglux.dao.implementation.ClasseDAOImpl@1c5466b]]; advisorChainFactory=org.springframework.aop.framew ork.HashMapCachingAdvisorChainFactory@922804expose Proxy=false; frozen=false; enableCglibSubclassOptimizations=false; aopProxyFactory=org.springframework.aop.framework. DefaultAopProxyFactory@1815338;
    WARN [hibernate.util.JDBCExceptionReporter:logExceptions] - SQL Error: 0, SQLState: null
    ERROR [hibernate.util.JDBCExceptionReporter:logExceptions] - Connection was closed in SingleConnectionDataSource. Check that user code checks shouldClose() before closing connections, or set suppressClose to true
    WARN [hibernate.util.JDBCExceptionReporter:logExceptions] - SQL Error: 0, SQLState: null
    ERROR [hibernate.util.JDBCExceptionReporter:logExceptions] - Connection was closed in SingleConnectionDataSource. Check that user code checks shouldClose() before closing connections, or set suppressClose to true
    ERROR [hibernate.util.JDBCExceptionReporter:<init>] - Cannot open connection
    java.sql.SQLException: Connection was closed in SingleConnectionDataSource. Check that user code checks shouldClose() before closing connections, or set suppressClose to true
    at org.springframework.jdbc.datasource.SingleConnecti onDataSource.getConnection(SingleConnectionDataSou rce.java:135)
    at org.springframework.orm.hibernate.LocalDataSourceC onnectionProvider.getConnection(LocalDataSourceCon nectionProvider.java:65)
    at net.sf.hibernate.impl.BatcherImpl.openConnection(B atcherImpl.java:286)
    at net.sf.hibernate.impl.SessionImpl.connect(SessionI mpl.java:3326)
    at net.sf.hibernate.impl.SessionImpl.connection(Sessi onImpl.java:3286)
    at net.sf.hibernate.impl.BatcherImpl.prepareQueryStat ement(BatcherImpl.java:65)
    at net.sf.hibernate.loader.Loader.prepareQueryStateme nt(Loader.java:779)
    at net.sf.hibernate.loader.Loader.doQuery(Loader.java :265)
    at net.sf.hibernate.loader.Loader.doQueryAndInitializ eNonLazyCollections(Loader.java:133)
    at net.sf.hibernate.loader.Loader.loadEntity(Loader.j ava:911)
    at net.sf.hibernate.loader.Loader.loadEntity(Loader.j ava:931)
    at net.sf.hibernate.loader.EntityLoader.load(EntityLo ader.java:59)
    at net.sf.hibernate.loader.EntityLoader.load(EntityLo ader.java:51)
    at net.sf.hibernate.persister.EntityPersister.load(En tityPersister.java:419)
    at net.sf.hibernate.impl.SessionImpl.doLoad(SessionIm pl.java:2117)
    at net.sf.hibernate.impl.SessionImpl.doLoadByClass(Se ssionImpl.java:1991)
    at net.sf.hibernate.impl.SessionImpl.load(SessionImpl .java:1920)
    at zorglux.dao.implementation.DAOImpl.loadPersistentC lass(DAOImpl.java:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:59 )
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:149)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :118)
    at org.springframework.orm.hibernate.HibernateInterce ptor.invoke(HibernateInterceptor.java:99)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:169)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:148)
    at $Proxy0.loadPersistentClass(Unknown Source)
    at zorglux.dao.TestDAO.testLoadPersistentClass(TestDA O.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:154 )
    at junit.framework.TestCase.runBare(TestCase.java:127 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:421)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:305)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:186)

    Well now if I use :
    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    instead of
    <bean id="myDataSource" class="org.springframework.jdbc.datasource.SingleC onnectionDataSource" destroy-method="close">

    Everything goes fine.

    Can anyone explain me what is the problem with SingleConnectionDataSource ?

    There is no urgence to that problem, I just want to know what goes wrong ...

    Seldrick

  • #2
    Something is calling close on the connection directly, so the next time you are trying to access the connection this exception is thrown. You could use a different datasource that does not rely on a single connection to remain open for the entire operation - like the DBCP BasicDataSource. Or, you could configure the SingleConnectionDataSource to prevent the connection from being closed by adding the following code to your DataSource configuration:
    Code:
    		<property name="suppressClose">
    		  <value>true</value>
    		</property>
    Also, you should call destroy() on the SingleConnectionDataSource at the end to force a close of the connection.

    Comment


    • #3
      adding the supressClose property solves the problem.

      Thanks for the explanation.

      I really think Spring is a valuable framework with lot of good ideas, but for me, it's not always easy to use, one way to help people like me would be to add more examples of Spring usage in the documentation.

      Long life to Spring.

      Seldrick

      Comment

      Working...
      X