title: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [jlcindia.xml]
body: <p>When I run my application, I'm getting the exception below:</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'sessionFactory' defined in class path resource [jlcindia.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:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
    at com.jlcindia.spring.hibernate.LAB27.main(LAB27.java:13)
  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:677)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 12 more
  Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 19; Document is invalid: no grammar found.
    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.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(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)
    ... 16 more
  </code></pre>
  
  <p>This is the <code>jlcindia.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
    &lt;context:annotation-config/&gt;
    &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/jlcindiadb"/&gt; 
      &lt;property name="username" value="root"/&gt;
      &lt;property name="password" value="santhosh"/&gt;
    &lt;/bean&gt; 
  
    &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" p:dataSource-ref="dataSource"&gt; 
      &lt;property name="mappingResources"&gt;
        &lt;list&gt; 
          &lt;value&gt;com/jlcindia/spring/hibernate/Customer.hbm.xml&lt;/value&gt;
        &lt;/list&gt;
      &lt;/property&gt; 
      &lt;property name="hibernateProperties"&gt;
        &lt;map&gt; 
          &lt;entry key="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/&gt;
          &lt;entry key="hibernate.show_sql" value="true"/&gt; 
          &lt;entry key="hibernate.hbm2ddl.auto" value="create"/&gt; 
        &lt;/map&gt; 
      &lt;/property&gt; 
    &lt;/bean&gt; 
  
    &lt;bean id="hibernateTemp" class="org.springframework.orm.hibernate3.HibernateTemplate" autowire="constructor"/&gt; 
    &lt;bean id="cdao" class="com.jlcindia.spring.hibernate.HibernateCustomerDAO"/&gt; 
    &lt;bean id="cs" class="com.jlcindia.spring.hibernate.CustomerServiceImpl"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>And the main class:</p>
  
  <pre><code>public class LAB27 { 
    public static void main(String[] args) {
      ApplicationContext ctx=new ClassPathXmlApplicationContext("jlcindia.xml"); 
      CustomerService cs=(CustomerService)ctx.getBean("cs"); 
      //1. addCustomer
      CustomerTO cto=new CustomerTO("san","s@jlc.com",98989,"bangalore");
      cs.addCustomer(cto);
    } 
  }
  </code></pre>
  
  <p>And the <code>Customer.hbm.xml</code></p>
  
  <pre><code>//Customer.hbm.xml
  &lt;hibernate-mapping package="com.jlcindia.spring.hibernate"&gt;
    &lt;class name="Customer" table="Customer" lazy="false"&gt;
      &lt;id name="cid" column="cid" type="int"&gt;
        &lt;generator class="increment"/&gt;
      &lt;/id&gt;
      &lt;property name="cname"/&gt;
      &lt;property name="email" /&gt;
      &lt;property name="phone" /&gt;
      &lt;property name="city"/&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Any help is greatly appreciated</p>