title: I have trouble setting up spring hibernate application-context.xml
body: <p>I am here trying integrate spring hibernate. this is the simple example which i am trying to run. i am getting error upon running] kindly help.</p>
  
  <blockquote>
    <p>EmployeeDAO.java</p>
  </blockquote>
  
  <pre><code>package com.spring.hibernate.dao;
  
  import com.spring.hibernate.bean.EmployeeBean;
  import org.springframework.orm.hibernate3.HibernateTemplate;
  
  public class EmployeeDAO {
      HibernateTemplate template;
  
      public void setTemplate(HibernateTemplate template) {
          this.template = template;
      }
  
      public void saveEmployee(EmployeeBean e){
          template.save(e);
      }
  
      public void deleteEmployee(EmployeeBean e){
          template.delete(e);
      }
  
      public void updateEmployee(EmployeeBean e){
          template.update(e);
      }
  }
  </code></pre>
  
  <blockquote>
    <p>EmployeeBean.java</p>
  </blockquote>
  
  <pre><code>package com.spring.hibernate.bean;
  
  
  public class EmployeeBean {
      private int emp_id,emp_age;
  
      public int getEmp_id() {
          return emp_id;
      }
  
      public void setEmp_id(int emp_id) {
          this.emp_id = emp_id;
      }
  
      public int getEmp_age() {
          return emp_age;
      }
  
      public void setEmp_age(int emp_age) {
          this.emp_age = emp_age;
      }
  
      public String getEmp_name() {
          return emp_name;
      }
  
      public void setEmp_name(String emp_name) {
          this.emp_name = emp_name;
      }
  
      public String getEmp_address() {
          return emp_address;
      }
  
      public void setEmp_address(String emp_address) {
          this.emp_address = emp_address;
      }
  
      public float getEmp_salary() {
          return emp_salary;
      }
  
      public void setEmp_salary(float emp_salary) {
          this.emp_salary = emp_salary;
      }
      private String emp_name, emp_address;
      private float emp_salary;
  }
  </code></pre>
  
  <blockquote>
    <p>SpringHibernateConsoole.java</p>
  </blockquote>
  
  <pre><code>package spring.hibernate.console;
  
  import com.spring.hibernate.bean.EmployeeBean;
  import com.spring.hibernate.dao.EmployeeDAO;
  import org.springframework.beans.factory.BeanFactory;
  import org.springframework.beans.factory.xml.XmlBeanFactory;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.core.io.Resource;
  
  public class SpringHibernateConsole {
  
  
      public static void main(String[] args) {
  
          Resource res = new ClassPathResource("applicationContext.xml");
  
          BeanFactory beanFactory = new XmlBeanFactory(res);
  
          EmployeeDAO dao = (EmployeeDAO)beanFactory.getBean("d");
  
          EmployeeBean emp = new EmployeeBean();
          emp.setEmp_id(23);
          emp.setEmp_name("amit");
          emp.setEmp_salary(15224);
          emp.setEmp_address("Ramakrishrna apratment new delhi");
          dao.saveEmployee(emp);
  
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>applicationContext.xml</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans  
      xmlns="http://www.springframework.org/schema/beans"  
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      xmlns:p="http://www.springframework.org/schema/p"  
      xsi:schemaLocation="http://www.springframework.org/schema/beans  
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;  
  
  
      &lt;bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
          &lt;property name="dirverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"&gt;&lt;/property&gt;
          &lt;property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=BFPL;instanceName=SQLEXPRESS;"&gt;&lt;/property&gt;
          &lt;property name="username" value="appuser" &gt;&lt;/property&gt;
          &lt;property name="password" value="commando"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="myDataSource"&gt;&lt;/property&gt;
          &lt;property name="mappingResources"&gt; 
              &lt;list&gt;
                  &lt;value&gt;employee.hbm.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
  
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.SQLServerDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
  
      &lt;/bean&gt;
  
      &lt;bean id="myTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"&gt;
          &lt;property name="sessionFactory" ref="mySessionFactory"&gt;&lt;/property&gt;
  
      &lt;/bean&gt;
  
      &lt;bean id="d" class="com.spring.hibernate.dao.EmployeeDAO"&gt;
          &lt;property name="template" ref="myTemplate"&gt;&lt;/property&gt;
      &lt;/bean&gt; 
  
  &lt;/beans&gt; 
  </code></pre>
  
  <blockquote>
    <p>employee.hbm</p>
  </blockquote>
  
  <pre><code>    &lt;?xml version='1.0' encoding='UTF-8'?&gt;  
  &lt;!DOCTYPE hibernate-mapping PUBLIC  
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;  
  
  &lt;hibernate-mapping&gt;
      &lt;class name="com.spring.hibernate.bean.EmployeeBean"&gt;
          &lt;id name="emp_id"&gt;
              &lt;generator class="assigned"&gt;&lt;/generator&gt;
          &lt;/id&gt;
          &lt;property name="emp_name"&gt;&lt;/property&gt;
          &lt;property name="emp_salary"&gt;&lt;/property&gt;
          &lt;property name="emp_address"&gt;&lt;/property&gt;
          &lt;property name="emp_age"&gt;&lt;/property&gt;    
      &lt;/class&gt;  
  
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <blockquote>
    <p>error : (Updated)</p>
  </blockquote>
  
  <pre><code>run:
  log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
  log4j:WARN Please initialize the log4j system properly.
  Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'd' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'myTemplate' while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myTemplate' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'mySessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(I)V
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1417)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at spring.hibernate.console.SpringHibernateConsole.main(SpringHibernateConsole.java:19)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myTemplate' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'mySessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(I)V
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1417)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
      ... 10 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(I)V
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:320)
      ... 20 more
  Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(I)V
      at net.sf.cglib.core.DebuggingClassWriter.&lt;init&gt;(DebuggingClassWriter.java:47)
      at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
      at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
      at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
      at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
      at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
      at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
      at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
      at net.sf.cglib.proxy.Enhancer.&lt;clinit&gt;(Enhancer.java:69)
      at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:107)
      at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
      at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
      at org.hibernate.tuple.entity.AbstractEntityTuplizer.&lt;init&gt;(AbstractEntityTuplizer.java:135)
      at org.hibernate.tuple.entity.PojoEntityTuplizer.&lt;init&gt;(PojoEntityTuplizer.java:55)
      at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.&lt;init&gt;(EntityEntityModeToTuplizerMapping.java:56)
      at org.hibernate.tuple.entity.EntityMetamodel.&lt;init&gt;(EntityMetamodel.java:269)
      at org.hibernate.persister.entity.AbstractEntityPersister.&lt;init&gt;(AbstractEntityPersister.java:425)
      at org.hibernate.persister.entity.SingleTableEntityPersister.&lt;init&gt;(SingleTableEntityPersister.java:109)
      at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
      at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:226)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:863)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:782)
      at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
      ... 27 more
  Java Result: 1
  BUILD SUCCESSFUL (total time: 8 seconds)
  </code></pre>