0 Replies Latest reply: Jun 7, 2008 7:22 AM by 843844 RSS

    applicationContext-hibernate.xml    con't  load

    843844
      My configuration is Spring2.5 netbeans6.0 Tomcat6.0.14 not having any single jar
      when i start my application it gives an error that applicationContext-hibernate.xml
      <code>
      SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [WEB-INF/applicationContext_1.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
      at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
      at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:516)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
      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:585)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:502)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:595)
      at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
      ... 38 more
      Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
      at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
      at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
      at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.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.dom4j.io.SAXReader.read(SAXReader.java:465)
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)

      </code>


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

      <!--
      - Application context definition for RoseIndia Login Application on Hibernate.
           -->
      <beans>

           <!-- ========================= RESOURCE DEFINITIONS ========================= -->

           <!-- Configurer that replaces ${...} placeholders with values from a properties file -->
           <!-- (in this case, JDBC-related settings for the dataSource definition below) -->
           <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                <property name="location"><value>/WEB-INF/jdbc.properties</value></property>
           </bean>

           <!-- Local DataSource that works in any environment -->
           <!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->
           
           <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                <property name="driverClassName"><value>${jdbc.driverClassName}</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>
           

           <!-- JNDI DataSource for J2EE environments -->

           <!-- Hibernate SessionFactory -->
           <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                <property name="dataSource"><ref local="dataSource"/></property>
                <property name="mappingResources">
                <list>
                     <value>roseindia/dao/hibernate/Login.hbm.xml</value>
                </list>
                </property>
                <property name="hibernateProperties">
                     <props>
                          <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                          <prop key="hibernate.show_sql">true</prop>
                     </props>
                </property>
           </bean>


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


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

           <!--
           Data access object: Hibernate implementation.
      -->

           <bean id="HibernateSpringDaoTarget" class="roseindia.dao.SpringHibernateDAOImpl">
                <property name="sessionFactory"><ref local="sessionFactory"/></property>
           </bean>

           <!--
                - Transactional proxy for Login Application central data access object.
                -
                - Defines specific transaction attributes with "readOnly" markers,
                - which is an optimization that is particularly valuable with Hibernate
                - (to suppress unnecessary flush attempts for read-only operations).
                -
                - Note that in a real-life app with multiple transaction proxies,
                - you will probably want to use parent and child bean definitions
                - as described in the manual, to reduce duplication.
      -->

           <bean id="SpringHibernateDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
                <property name="transactionManager"><ref local="transactionManager"/></property>
                <property name="target"><ref local="HibernateSpringDaoTarget"/></property>
                <property name="transactionAttributes">
                     <props>
                          <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                          <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                          <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
                          <prop key="store*">PROPAGATION_REQUIRED</prop>
                     </props>
                </property>
           </bean>

           <!-- Email Service-->
           <bean id="mailbean" class="roseindia.web.common.SendMail">
                <property name="strSmtp"><value>mail.waproductsuite.com</value></property>
           </bean>

      </beans>

      </code>