Announcement Announcement Module
Collapse
No announcement yet.
proble loading applicationContext-hybernate.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • proble loading applicationContext-hybernate.xml

    In my spring_mvc+hybernate i used the following code

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>


    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext-hibernate.xml
    /WEB-INF/trailapp-servlet.xml</param-value>
    </context-param>

    <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>org.springframework.web.context.ContextLoade rServlet </servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>



    The app is loading only trailapp-servlet.xml which consists of web tier code but it is not loading hybernate code which is configured in applicationContext-hybernate.xml


    Any help will be appreciated

  • #2
    You need a comma between the two contexts.

    Please use the code tags when you post code/xml.

    cheers

    G

    Comment


    • #3
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with nam

      could you please tell me why this error is occuring very urgent

      org.springframework.beans.factory.BeanCreationExce ption:
      Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFac toryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory




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

      <beans>


      <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
      <property name="sessionFactory">
      <ref bean="sessionFactory"/>
      </property>
      </bean>

      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
      <property name="dataSource" ref ="dataSource"/>
      <property name="mappingResources">
      <list>
      <value>com/beans/user.hbm.xml</value>
      <value>com/beans/Phone_Map.hbm.xml</value>
      </list>
      </property>

      <property name="hibernateProperties">
      <props>
      <prop key="hibernate.dialect">${hibernate.dialect}</prop>
      <prop key="hibernate.show_sql">true</prop>
      <prop key="hibernate.hbm2ddl.auto">update</prop>
      </props>
      </property>
      </bean>


      <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
      <property name="location"><value>/WEB-INF/jdbc.properties</value></property>
      </bean>

      <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
      <property name="driverClassName"><value>${jdbc.driverClassNa me}</value></property>
      <property name="url"><value>${jdbc.url}</value></property>
      <property name="username"><value>${jdbc.username}</value></property>
      <property name="password"><value>${jdbc.password}</value></property>
      </bean>


      <!-- Hibernate SessionFactory -->



      <bean id="openSessionInView" class="org.springframework.orm.hibernate3.support. OpenSessionInViewFilter">
      <property name="sessionFactoryBeanName"><ref local="sessionFactory"/></property>
      </bean>


      <bean id="userbo" class="com.business.userboimpl">
      <property name="sessionFactory"><ref local="sessionFactory"/></property>
      </bean>


      </beans>

      Comment


      • #4
        The root cause of the problem is: NoClassDefFoundError: org/slf4j/LoggerFactory

        You have to add a jar-file for sl4j yo the class path. This is a dependency of Hibernate.

        G

        Comment

        Working...
        X