Announcement Announcement Module
Collapse
No announcement yet.
Does Spring 1.2.8 support Hibernate 3.1? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does Spring 1.2.8 support Hibernate 3.1?

    I'm getting the following error:

    15:17:20,337 ERROR [/UrbanCanyons]:3733 - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException
    java.lang.NullPointerException

    Does anyone have any idea what my problem might be?

    Here is my applicationContext-hibernate.xml file:

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

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

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName">
    <value>org.gjt.mm.mysql.Driver</value>
    </property>
    <property name="url">
    <value>jdbc:mysql://localhost/urbancanyons</value>
    </property>
    <property name="username"><value>uc</value></property>
    <property name="password"><value>uc</value></property>
    </bean>

    <!-- Choose the dialect that matches your "dataSource" definition -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource"><ref local="dataSource"/></property>
    <property name="mappingResources">
    <list>
    <value>org/coastal/urbancanyons/hq/mapping/Address.hbm.xml </value>
    <value>org/coastal/urbancanyons/hq/mapping/Alert.hbm.xml </value>
    <value>org/coastal/urbancanyons/hq/mapping/Building.hbm.xml </value>
    <value>org/coastal/urbancanyons/hq/mapping/ChatMessage.hbm.xml </value>
    <value>org/coastal/urbancanyons/hq/mapping/State.hbm.xml </value>
    <value>org/coastal/urbancanyons/hq/mapping/User.hbm.xml </value>
    <value>org/coastal/urbancanyons/hq/mapping/EmailAddress.hbm.xml</value>
    <value>org/coastal/urbancanyons/hq/mapping/Role.hbm.xml </value>
    <value>org/coastal/urbancanyons/hq/mapping/PhoneNumber.hbm.xml </value>
    </list>
    </property>

    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.H SQLDialect</prop>
    <prop key="hibernate.hbm2ddl.auto">create</prop>
    </props>
    </property>
    </bean>

    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate.Hibernate TransactionManager">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>


    <!-- ***** ALERT SERVICE *****-->
    <bean id="alertService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="transactionManager"/></property>
    <property name="target"><ref local="alertTarget"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="remove*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>

    <!-- AlertTarget primary business object implementation -->
    <bean id="alertTarget" class="org.coastal.urbancanyons.facade.AlertFacade SpringImpl">
    <property name="alertDAO"><ref local="alertDAO"/></property>
    </bean>

    <!-- DAO object: Hibernate implementation -->
    <bean id="alertDAO" class="org.coastal.urbancanyons.dao.AlertHibernate DAO">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    <!-- Add more services here -->

    </beans>
    Last edited by jdcyuen; Jun 12th, 2006, 06:59 PM.

  • #2
    Use
    Code:
    org.springframework.orm.hibernate3.LocalSessionFactoryBean
    and
    Code:
    org.springframework.orm.hibernate3.HibernateTransactionManager
    instead of
    Code:
    org.springframework.orm.hibernate.LocalSessionFactoryBean
    and
    Code:
    org.springframework.orm.hibernate.HibernateTransactionManager

    Comment


    • #3
      Does Spring 1.2.8 support Hibernate 3.1?

      Thanks, I made those changes and it got me a little further. But now I get the following stack trace:


      10:23:48,236 ERROR ContextLoader:211 - Context initialization failed
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class
      org.hibernate.HibernateException: Could not instantiate dialect class
      at org.hibernate.dialect.DialectFactory.buildDialect( DialectFactory.java:84)
      at org.hibernate.dialect.DialectFactory.buildDialect( DialectFactory.java:42)
      at org.hibernate.cfg.SettingsFactory.determineDialect (SettingsFactory.java:378)
      at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:110)
      at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1881)
      at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1174)
      at org.springframework.orm.hibernate3.LocalSessionFac toryBean.newSessionFactory(LocalSessionFactoryBean .java:825)
      at org.springframework.orm.hibernate3.LocalSessionFac toryBean.afterPropertiesSet(LocalSessionFactoryBea n.java:751)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1091)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:396)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
      at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:277)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:313)
      at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:139)
      at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:252)
      at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:190)
      at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
      at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3729)
      at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4183)
      at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:759)
      at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:739)
      at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:524)
      at org.apache.catalina.startup.HostConfig.deployWAR(H ostConfig.java:809)
      at org.apache.catalina.startup.HostConfig.deployWARs( HostConfig.java:698)
      at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:472)
      at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1112)
      at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:310)
      at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1021)
      at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:718)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1013)
      at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:442)
      at org.apache.catalina.core.StandardService.start(Sta ndardService.java:450)
      at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:709)
      at org.apache.catalina.startup.Catalina.start(Catalin a.java:551)
      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:275)
      at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:413)
      Caused by: java.lang.ClassCastException: net.sf.hibernate.dialect.HSQLDialect
      at org.hibernate.dialect.DialectFactory.buildDialect( DialectFactory.java:78)
      ... 41 more
      10:23:48,236 ERROR [/UrbanCanyons]:3733 - Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class
      org.hibernate.HibernateException: Could not instantiate dialect class
      at org.hibernate.dialect.DialectFactory.buildDialect( DialectFactory.java:84)
      at org.hibernate.dialect.DialectFactory.buildDialect( DialectFactory.java:42)
      at org.hibernate.cfg.SettingsFactory.determineDialect (SettingsFactory.java:378)
      at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:110)
      at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1881)
      at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1174)
      at org.springframework.orm.hibernate3.LocalSessionFac toryBean.newSessionFactory(LocalSessionFactoryBean .java:825)
      at org.springframework.orm.hibernate3.LocalSessionFac toryBean.afterPropertiesSet(LocalSessionFactoryBea n.java:751)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1091)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:396)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
      at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:277)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:313)
      at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:139)
      at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:252)
      at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:190)
      at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 49)
      at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3729)
      at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4183)
      at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:759)
      at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:739)
      at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:524)
      at org.apache.catalina.startup.HostConfig.deployWAR(H ostConfig.java:809)
      at org.apache.catalina.startup.HostConfig.deployWARs( HostConfig.java:698)
      at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:472)
      at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1112)
      at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:310)
      at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1021)
      at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:718)
      at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1013)
      at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:442)
      at org.apache.catalina.core.StandardService.start(Sta ndardService.java:450)
      at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:709)
      at org.apache.catalina.startup.Catalina.start(Catalin a.java:551)
      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:275)
      at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:413)
      Caused by: java.lang.ClassCastException: net.sf.hibernate.dialect.HSQLDialect
      at org.hibernate.dialect.DialectFactory.buildDialect( DialectFactory.java:78)
      ... 41 more

      Comment


      • #4
        Change
        Code:
        net.sf.hibernate.dialect.HSQLDialect
        to
        Code:
        org.hibernate.dialect.HSQLDialect

        Comment


        • #5
          If you're migrating, you might find this thread helpful.

          Comment

          Working...
          X