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

  • Tomcat + Spring + Hibernate configuration problem

    Hi all,

    Can you help me solving a configuration problem between with tomcat, spring and hibernate ?

    I would like Hibernate to use a datasource defined in JNDI, it seems that Hibernate can't access my "JNDI" datasource (well I'm not sure to clearly understand the problem).

    here's my application context :

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

    <beans>

    <!--data source definition-->
    <bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:comp/env/MySqlDatasource</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>


    <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>
    </beans>

    here's the log of tomcat startup with debug level for spring :

    27 août 2004 01:49:12 org.apache.coyote.http11.Http11Protocol init
    INFO: Initialisation de Coyote HTTP/1.1 sur http-8080
    27 août 2004 01:49:12 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 2329 ms
    27 août 2004 01:49:12 org.apache.catalina.core.StandardService start
    INFO: Démarrage du service Catalina
    27 août 2004 01:49:12 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.0.27
    27 août 2004 01:49:12 org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    27 août 2004 01:49:12 org.apache.catalina.core.StandardHost getDeployer
    INFO: Create Host deployer for direct deployment ( non-jmx )
    27 août 2004 01:49:12 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\admin.xml
    27 août 2004 01:49:14 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
    27 août 2004 01:49:14 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
    27 août 2004 01:49:15 org.apache.struts.util.PropertyMessageResources <init>
    INFO: Initializing, config='org.apache.webapp.admin.ApplicationResourc es', returnNull=true
    27 août 2004 01:49:18 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\balancer.xml
    27 août 2004 01:49:19 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\jsp-examples.xml
    log4j:WARN No appenders could be found for logger (org.apache.catalina.session.ManagerBase).
    log4j:WARN Please initialize the log4j system properly.
    27 août 2004 01:49:21 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\manager.xml
    27 août 2004 01:49:22 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\ROOT.xml
    27 août 2004 01:49:22 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\servlets-examples.xml
    27 août 2004 01:49:24 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\tomcat-docs.xml
    27 août 2004 01:49:24 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\webdav.xml
    27 août 2004 01:49:25 org.apache.catalina.core.StandardHostDeployer install
    INFO: Processing Context configuration file URL file:E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\zorglux.xml
    StandardContext[/zorglux]Loading root WebApplicationContext
    INFO [org.springframework.beans.factory.xml.XmlBeanDefin itionReader:loadBeanDefinitions] - Loading XML bean definitions from resource [/WEB-INF/applicationContext.xml] of ServletContext
    DEBUG [org.springframework.beans.factory.xml.XmlBeanDefin itionReader:loadBeanDefinitions] - Using JAXP implementation [org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@ cd6aa0]
    DEBUG [org.springframework.context.support.ResourceEntity Resolver:resolveEntity] - Trying to resolve XML entity with public ID [-//SPRING//DTD BEAN//EN] and system ID [http://www.springframework.org/dtd/spring-beans.dtd]
    DEBUG [org.springframework.context.support.ResourceEntity Resolver:resolveEntity] - Trying to locate [spring-beans.dtd] under [/org/springframework/beans/factory/xml/]
    DEBUG [org.springframework.context.support.ResourceEntity Resolver:resolveEntity] - Found beans DTD [http://www.springframework.org/dtd/spring-beans.dtd] in classpath
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:registerBeanDefinitions] - Loading bean definitions
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:registerBeanDefinitions] - Default lazy init 'false'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:registerBeanDefinitions] - Default dependency check 'none'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:registerBeanDefinitions] - Default autowire 'no'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myDataSource'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'sessionFactory'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myHibernateInterceptor'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myTransactionManager'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myTransactionInterceptor'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myDAOTarget'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myDAO'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myTokenSetDAOTarget'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myTokenSetDAO'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myRaceDAOTarget'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myRaceDAO'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myClasseDAOTarget'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:loadBeanDefinition] - Registering bean definition with id 'myClasseDAO'
    DEBUG [org.springframework.beans.factory.xml.DefaultXmlBe anDefinitionParser:registerBeanDefinitions] - Found 13 <bean> elements defining beans
    INFO [org.springframework.web.context.support.XmlWebAppl icationContext:refreshBeanFactory] - Bean factory for application context [Root XmlWebApplicationContext]: 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 [org.springframework.web.context.support.XmlWebAppl icationContext:refresh] - 13 beans defined in ApplicationContext [Root XmlWebApplicationContext]
    INFO [org.springframework.web.context.support.XmlWebAppl icationContext:initMessageSource] - No MessageSource found for [Root XmlWebApplicationContext]: using empty StaticMessageSource
    INFO [org.springframework.ui.context.support.UiApplicati onContextUtils:initThemeSource] - No ThemeSource found for [Root XmlWebApplicationContext]: using ResourceBundleThemeSource
    INFO [org.springframework.web.context.support.XmlWebAppl icationContext:refreshListeners] - Refreshing listeners
    DEBUG [org.springframework.web.context.support.XmlWebAppl icationContext:refreshListeners] - Found 0 listeners in bean factory
    INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactoryreInstantiateSingletons] - 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 [org.springframework.beans.factory.support.DefaultL istableBeanFactory:getBean] - Creating shared instance of singleton bean 'myDataSource'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:createBean] - Creating instance of bean 'myDataSource' with merged definition [Root bean with class [org.springframework.jndi.JndiObjectFactoryBean] defined in resource [/WEB-INF/applicationContext.xml] of ServletContext]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Getting BeanInfo for class [org.springframework.jndi.JndiObjectFactoryBean]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Caching PropertyDescriptors for class [org.springframework.jndi.JndiObjectFactoryBean]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'class' of type [class java.lang.Class]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'jndiEnvironment' of type [class java.util.Properties]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'jndiName' of type [class java.lang.String]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'jndiTemplate' of type [class org.springframework.jndi.JndiTemplate]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'object' of type [class java.lang.Object]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'objectType' of type [class java.lang.Class]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'resourceRef' of type [boolean]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'singleton' of type [boolean]; editor=[null]
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - About to invoke write method [public final void org.springframework.jndi.AbstractJndiLocator.setJn diName(java.lang.String)] on object of class [org.springframework.jndi.JndiObjectFactoryBean]
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - Invoked write method [public final void org.springframework.jndi.AbstractJndiLocator.setJn diName(java.lang.String)] with value [java:comp/env/MySqlDatasource]
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:applyBeanPostProcessorsBeforeIn itialization] - Invoking BeanPostProcessors before initialization of bean 'myDataSource'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:invokeInitMethods] - Calling afterPropertiesSet() on bean with beanName 'myDataSource'
    DEBUG [org.springframework.jndi.JndiTemplate:doInContext] - Looking up JNDI object with name 'java:comp/env/MySqlDatasource'
    DEBUG [org.springframework.jndi.JndiObjectFactoryBean:loo kup] - Successfully looked up object with jndiName 'java:comp/env/MySqlDatasource': value=[org.apache.commons.dbcp.BasicDataSource@186ed7a]
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:applyBeanPostProcessorsAfterIni tialization] - Invoking BeanPostProcessors after initialization of bean 'myDataSource'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:getObjectForSharedInstance] - Calling code asked for FactoryBean instance for name 'myDataSource'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:getBean] - Returning cached instance of singleton bean 'myDataSource'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:getObjectForSharedInstance] - Bean with name 'myDataSource' is a factory bean
    INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory:getBean] - Creating shared instance of singleton bean 'sessionFactory'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:createBean] - Creating instance of bean 'sessionFactory' with merged definition [Root bean with class [org.springframework.orm.hibernate.LocalSessionFact oryBean] defined in resource [/WEB-INF/applicationContext.xml] of ServletContext]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Getting BeanInfo for class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Caching PropertyDescriptors for class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'class' of type [class java.lang.Class]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'configLocation' of type [interface org.springframework.core.io.Resource]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'configuration' of type [class net.sf.hibernate.cfg.Configuration]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'dataSource' of type [interface javax.sql.DataSource]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'entityInterceptor' of type [interface net.sf.hibernate.Interceptor]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'hibernateProperties' of type [class java.util.Properties]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'jtaTransactionManager' of type [interface javax.transaction.TransactionManager]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'lobHandler' of type [interface org.springframework.jdbc.support.lob.LobHandler]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'mappingDirectoryLocations' of type [class [Lorg.springframework.core.io.Resource;]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'mappingJarLocations' of type [class [Lorg.springframework.core.io.Resource;]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'mappingLocations' of type [class [Lorg.springframework.core.io.Resource;]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'mappingResources' of type [class [Ljava.lang.String;]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'object' of type [class java.lang.Object]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'objectType' of type [class java.lang.Class]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'schemaUpdate' of type [boolean]; editor=[null]
    DEBUG [org.springframework.beans.CachedIntrospectionResul ts:<init>] - Found property 'singleton' of type [boolean]; editor=[null]
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:resolveReference] - Resolving reference from property 'dataSource' in bean 'sessionFactory' to bean 'myDataSource'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:getBean] - Returning cached instance of singleton bean 'myDataSource'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:getObjectForSharedInstance] - Bean with name 'myDataSource' is a factory bean
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - About to invoke write method [public void org.springframework.orm.hibernate.LocalSessionFact oryBean.setMappingResources(java.lang.String[])] on object of class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - Invoked write method [public void org.springframework.orm.hibernate.LocalSessionFact oryBean.setMappingResources(java.lang.String[])] with value [[Ljava.lang.String;@f6398]
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - About to invoke write method [public void org.springframework.orm.hibernate.LocalSessionFact oryBean.setHibernateProperties(java.util.Propertie s)] on object of class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - Invoked write method [public void org.springframework.orm.hibernate.LocalSessionFact oryBean.setHibernateProperties(java.util.Propertie s)] with value of type [java.util.Properties]
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - About to invoke write method [public void org.springframework.orm.hibernate.LocalSessionFact oryBean.setDataSource(javax.sql.DataSource)] on object of class [org.springframework.orm.hibernate.LocalSessionFact oryBean]
    DEBUG [org.springframework.beans.BeanWrapperImpl:setPrope rtyValue] - Invoked write method [public void org.springframework.orm.hibernate.LocalSessionFact oryBean.setDataSource(javax.sql.DataSource)] with value of type [javax.sql.DataSource]
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:applyBeanPostProcessorsBeforeIn itialization] - Invoking BeanPostProcessors before initialization of bean 'sessionFactory'
    DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory:invokeInitMethods] - Calling afterPropertiesSet() on bean with beanName 'sessionFactory'
    INFO [net.sf.hibernate.cfg.Environment:<clinit>] - Hibernate 2.1.6
    INFO [net.sf.hibernate.cfg.Environment:<clinit>] - hibernate.properties not found
    INFO [net.sf.hibernate.cfg.Environment:<clinit>] - using CGLIB reflection optimizer
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.attribut.Attribute -> attribut
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.attribut.CaracteristiquesRan k -> CARACTERISTIQUES_RANK
    INFO [net.sf.hibernate.cfg.Binder:bindCollection] - Mapping collection: zorglux.objetsmetiers.attribut.CaracteristiquesRan k.ranks -> RANKS
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.inominax.Token -> TOKEN
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.inominax.TokenSet -> TOKEN_SET
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.personnage.classe.Classe -> CLASSE
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.personnage.level.XPLevelProg ression -> XP_LEVEL_PROGRESSION
    INFO [net.sf.hibernate.cfg.Binder:bindSubclass] - Mapping subclass: zorglux.objetsmetiers.personnage.level.Mathematica lXPLevelProgression -> XP_LEVEL_PROGRESSION
    INFO [net.sf.hibernate.cfg.Binder:bindSubclass] - Mapping subclass: zorglux.objetsmetiers.personnage.level.UserDefined XPLevelProgression -> XP_LEVEL_PROGRESSION
    INFO [net.sf.hibernate.cfg.Binder:bindCollection] - Mapping collection: zorglux.objetsmetiers.personnage.level.UserDefined XPLevelProgression.allXPLevel -> XP_LEVEL_VALUES
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.personnage.race.Race -> RACE
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.rules.Rule -> RULE
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.rules.Ajustement -> AJUSTEMENT
    INFO [net.sf.hibernate.cfg.Binder:bindRootClass] - Mapping class: zorglux.objetsmetiers.rules.GroupOfAjustements -> ADJUSTMENTS_GROUP
    INFO [org.springframework.orm.hibernate.LocalSessionFact oryBean:afterPropertiesSet] - Building new Hibernate SessionFactory
    INFO [net.sf.hibernate.cfg.Configuration:secondPassCompi le] - processing one-to-many association mappings
    INFO [net.sf.hibernate.cfg.Binder:bindCollectionSecondPa ss] - Mapping collection: zorglux.objetsmetiers.inominax.TokenSet.setOfToken s -> TOKEN
    INFO [net.sf.hibernate.cfg.Binder:bindCollectionSecondPa ss] - Mapping collection: zorglux.objetsmetiers.rules.GroupOfAjustements.aju stements -> AJUSTEMENT
    INFO [net.sf.hibernate.cfg.Configuration:secondPassCompi le] - processing one-to-one association property references
    INFO [net.sf.hibernate.cfg.Configuration:secondPassCompi le] - processing foreign key constraints
    INFO [net.sf.hibernate.dialect.Dialect:<init>] - Using dialect: net.sf.hibernate.dialect.MySQLDialect
    INFO [net.sf.hibernate.cfg.SettingsFactory:buildSettings] - Maximim outer join fetch depth: 2
    INFO [net.sf.hibernate.cfg.SettingsFactory:buildSettings] - Use outer join fetching: true
    INFO [net.sf.hibernate.connection.ConnectionProviderFact ory:newConnectionProvider] - Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceC onnectionProvider
    INFO [net.sf.hibernate.transaction.TransactionFactoryFac tory:buildTransactionFactory] - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactor y
    INFO [net.sf.hibernate.transaction.TransactionManagerLoo kupFactory:getTransactionManagerLookup] - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    WARN [net.sf.hibernate.util.JDBCExceptionReporter:logExc eptions] - SQL Error: 0, SQLState: null
    ERROR [net.sf.hibernate.util.JDBCExceptionReporter:logExc eptions] - Cannot create JDBC driver of class '' for connect URL 'null'
    WARN [net.sf.hibernate.cfg.SettingsFactory:buildSettings] - Could not obtain connection metadata
    org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
    at org.apache.commons.dbcp.BasicDataSource.createData Source(BasicDataSource.java:780)
    at org.apache.commons.dbcp.BasicDataSource.getConnect ion(BasicDataSource.java:540)
    at org.springframework.orm.hibernate.LocalDataSourceC onnectionProvider.getConnection(LocalDataSourceCon nectionProvider.java:65)
    at net.sf.hibernate.cfg.SettingsFactory.buildSettings (SettingsFactory.java:73)
    at net.sf.hibernate.cfg.Configuration.buildSettings(C onfiguration.java:1155)
    at net.sf.hibernate.cfg.Configuration.buildSessionFac tory(Configuration.java:789)
    at org.springframework.orm.hibernate.LocalSessionFact oryBean.newSessionFactory(LocalSessionFactoryBean. java:417)
    at org.springframework.orm.hibernate.LocalSessionFact oryBean.afterPropertiesSet(LocalSessionFactoryBean .java:355)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:718)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:213)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:159)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:172)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:272)
    at org.springframework.web.context.support.XmlWebAppl icationContext.refresh(XmlWebApplicationContext.ja va:131)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:154)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:95)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 48)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3827)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4343)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:823)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:807)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:595)
    at org.apache.catalina.core.StandardHostDeployer.addC hild(StandardHostDeployer.java:903)
    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.apache.commons.beanutils.MethodUtils.invokeMet hod(MethodUtils.java:252)
    at org.apache.commons.digester.SetNextRule.end(SetNex tRule.java:256)
    at org.apache.commons.digester.Rule.end(Rule.java:276 )
    at org.apache.commons.digester.Digester.endElement(Di gester.java:1058)
    at org.apache.catalina.util.CatalinaDigester.endEleme nt(CatalinaDigester.java:76)
    at org.apache.xerces.parsers.AbstractSAXParser.endEle ment(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digeste r.java:1567)
    at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDeployer.java:488)
    at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:863)
    at org.apache.catalina.startup.HostConfig.deployDescr iptors(HostConfig.java:482)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:427)
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:968)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:349)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1091)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:789)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:478)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:480)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:2313)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:556)
    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.apache.catalina.startup.Bootstrap.start(Bootst rap.java:284)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:422)
    Caused by: java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getDriver(Unknown Source)
    at org.apache.commons.dbcp.BasicDataSource.createData Source(BasicDataSource.java:773)
    ... 60 more


    Thanks for your help,

  • #2
    The log/stackTrace says Spring got access succefuly to dataSource
    DEBUG [org.springframework.jndi.JndiObjectFactoryBean:loo kup] - Successfully looked up object with jndiName 'java:comp/env/MySqlDatasource': value=[org.apache.commons.dbcp.BasicDataSource@186ed7a]
    but DBCP fails to create a JDBC connection
    ERROR [net.sf.hibernate.util.JDBCExceptionReporter:logExc eptions] - Cannot create JDBC driver of class '' for connect URL 'null'
    Could you show the content of file
    Code:
    E&#58;\Programmation\Tomcat 5.0\conf\Catalina\localhost\zorglux.xml

    Comment


    • #3
      This looks like it has nothing to do with Spring, but rather your DataSource is set up badly. The JDBC url is not one that DriverManager recognizes...

      Comment


      • #4
        Thanks for the response,

        Omar here's zorglux.xml content, I made a reference to MySqlDatasource which is correctly accessed by Spring as you said.

        <?xml version='1.0' encoding='utf-8'?>
        <Context displayName="Zorglux"
        docBase="E:/Programmation/Eclipse/workspace/Zorglux/webapp"
        path="/zorglux"
        reloadable="true"
        workDir="E:\Programmation\Eclipse\workspace\Zorglu x\work">
        <Logger className="org.apache.catalina.logger.SystemOutLog ger" verbosity="3"/>
        <resource-ref>
        <res-ref-name>MySqlDatasource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        </resource-ref>

        </Context>

        Now maybe this datasource is not correctly defined in Tomcat resources.
        Can you tell me if the following Tomcat configuration file server.xml seems correct to you ? (blue text is MySqlDatasource configuration)

        <?xml version='1.0' encoding='utf-8'?>
        <Server>
        <Listener className="org.apache.catalina.mbeans.ServerLifecy cleListener"/>
        <Listener className="org.apache.catalina.mbeans.GlobalResour cesLifecycleListener"/>
        <GlobalNamingResources>
        <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
        <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
        <Resource name="MySqlDatasource" type="javax.sql.DataSource"/>
        <ResourceParams name="UserDatabase">
        <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabas eFactory</value>
        </parameter>
        <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
        </parameter>
        </ResourceParams>
        <ResourceParams name="MySqlDatasource">
        <parameter>
        <name>maxWait</name>
        <value>5000</value>
        </parameter>
        <parameter>
        <name>maxActive</name>
        <value>4</value>
        </parameter>
        <parameter>
        <name>password</name>
        <value>zogzogzog</value>
        </parameter>
        <parameter>
        <name>url</name>
        <value>jdbc:mysql:/localhost:3306/Zorglux</value>
        </parameter>
        <parameter>
        <name>driverClassName</name>
        <value>org.gjt.mm.mysql.Driver</value>
        </parameter>
        <parameter>
        <name>maxIdle</name>
        <value>2</value>
        </parameter>
        <parameter>
        <name>username</name>
        <value>u_Zorglux</value>
        </parameter>
        </ResourceParams>
        </GlobalNamingResources>
        <Service name="Catalina">
        <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
        </Connector>
        <Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkC oyoteHandler" redirectPort="8443">
        </Connector>
        <Engine defaultHost="localhost" name="Catalina">
        <Host appBase="webapps" name="localhost">
        <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
        </Host>
        <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
        <Realm className="org.apache.catalina.realm.UserDatabaseR ealm"/>
        </Engine>
        </Service>
        </Server>

        ERROR [net.sf.hibernate.util.JDBCExceptionReporter:logExc eptions] - Cannot create JDBC driver of class '' for connect URL 'null'
        This error is strange to me because I have set the driver class name and url in the datasource configuration, it seems that MySqlDatasource configuration is not well retrieved or that DriverManager does not use MySqlDatasource.

        Maybe I could define JDBC connection properties in hibernateProperties directly but that would mean not using MySqlDatasource JNDI datasource anymore (which the option I prefer).

        Is there a way to check JNDI datasource properties from Spring logs to know if MySqlDatasource properties are correctly retrieved ?

        Comment


        • #5
          Colin was right, it is a datasource configuration problem in Tomcat, not in Spring.

          I have written a JSP Test page retrieving MySqlDatasource and executing a query, I have the same error about a null URL and no deriver class name.

          I don't know where is my mistake but I'm investigating ...

          Thanks for responding to a non-spring problem.

          Comment


          • #6
            Colin was right, it is a datasource configuration problem in Tomcat, not in Spring.
            of course, and that's why I asked for file
            Code:
            E&#58;\Programmation\Tomcat 5.0\conf\Catalina\localhost\zorglux.xml
            Now to solve your problem, you need to remove the Context / datasource configuration from server.xml and put it into E:\Programmation\Tomcat 5.0\conf\Catalina\localhost\zorglux.xml. You should keep mysql jar file into %CATALINA_HOME%\common/lib.
            I put no references to Contexts inside server.xml and it works nicely.

            HTH

            Comment

            Working...
            X