title: Spring BeanCreationException: Error creating bean with name 'accountDaoBean'
body: <p>[enter image description here][1]</p>
  
  <p>Account.java</p>
  
  <pre><code>package com.hibernateWithSpring;
  public class Account {
  private int accountNumber;
  private String owner;
  private double balance;
  
  public Account(){
  }
  
  public Account(int accountNumber, String owner, double balance) {
  this.accountNumber=accountNumber;
  this.owner= owner;
  this.balance=balance;
  }
  
  public int getAccountNumber() {
  return accountNumber;
  }
  public void setAccountNumber(int accountNumber) {
  this.accountNumber = accountNumber;
  }
  public String getOwner() {
  return owner;
  }
  public void setOwner(String owner) {
  this.owner = owner;
  }
  public double getBalance() {
  return balance;
  }
  public void setBalance(double balance) {
  this.balance = balance;
  }
  
  }
  </code></pre>
  
  <p>AccountClient.java</p>
  
  <pre><code> package com.hibernateWithSpring;
   import java.util.List;
   import org.springframework.context.ApplicationContext; 
   import org.springframework.context.support.FileSystemXmlApplicationContext;
  
   public class AccountClient {
  
   public static void main(String[] args){
  
      ApplicationContext context=new             FileSystemXmlApplicationContext("bin/beans.xml");
      AccountDao accountdao = context.getBean("accountDaoBean",AccountDao.class);
      accountdao.createAccount(110, "varun",1000);
      accountdao.createAccount(111, "vicky",1200);
      System.out.println("account created");
      accountdao.updateBalance(111,2222);
      System.out.println("account updated");
      accountdao.deleteAccount(111);
      System.out.println("account deleted");
  
  
      List&lt;Account&gt; account= accountdao.getAllAccount();
      for(int i=0;i&lt;account.size();i++){
          Account acc=account.get(i);
                 System.out.println(acc.getAccountNumber()+":"+acc.getOwner()+":"+acc.getBalance());
      }
  
  }
  }
  </code></pre>
  
  <p>AccountDao.java</p>
  
  <pre><code> package com.hibernateWithSpring;
   import java.util.List;
  
   import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
  
   public class AccountDao extends HibernateDaoSupport
   {
  
  public void createAccount(int accountNumbeer, String owner, double balane){
      Account account= new Account(accountNumbeer,owner,balane);
      getHibernateTemplate().save(account); 
  }
  
  public void updateBalance(int accountNumber, double newBalance){
      Account account= getHibernateTemplate().get(Account.class, accountNumber);
      if(account !=null){
          account.setBalance(newBalance);
      }
      getHibernateTemplate().update(account);
  }
  public void deleteAccount(int accountNumber){
      Account account=getHibernateTemplate().get(Account.class, accountNumber);
              if(account!=null){
                  getHibernateTemplate().delete(account);
              }
  }
  
  @SuppressWarnings("unchecked")
  public List&lt;Account&gt; getAllAccount()
  {
      return getHibernateTemplate().find("from Account");
  }
  
  }
  </code></pre>
  
  <p>Account.hbm.xml</p>
  
  <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.hibernateWithSpring.Account" table="account"&gt;
      &lt;id name="accountNumber" column="account_number" type="int"&gt;&lt;/id&gt;
      &lt;property name="owner" column="owner" type="string"&gt;&lt;/property&gt;
      &lt;property name="balance" column="balance" type="double"&gt;&lt;/property&gt;
  &lt;/class&gt;
   &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>beans.xml</p>
  
  <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"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
  
  &lt;bean id="accountDaoBean" class="com.hibernateWithSpring.AccountDao"&gt;
  &lt;property name="hibernateTemplate" ref="hibernateTemplateBean"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="hibernateTemplateBean" class="org.springframework.orm.hibernate3.HibernateTemplate"&gt;
      &lt;property name="sessionFactory" ref="sfBean"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;bean id="sfBean" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
  &lt;property name="dataSource" ref="dataSourceBean"&gt;&lt;/property&gt;
  &lt;property name="mappingResources"&gt;
      &lt;value&gt;com/hibernateWithSpring/Account.hbm.xml&lt;/value&gt;
  &lt;/property&gt; 
  
  &lt;property name="hibernateProperties"&gt;
  &lt;props&gt;
  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
  &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
  &lt;/props&gt;
  &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="dataSourceBean" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
  &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"&gt;&lt;/property&gt;
  &lt;property name="url" value="jdbc:mysql://localhost:3306/accountdb"&gt;&lt;/property&gt;
  &lt;property name="username" value="root"&gt;&lt;/property&gt;
  &lt;property name="password" value="root"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>My db Details are correct But I have no idea why i am getting this error:-</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountDaoBean' defined in file [E:\new project\marsWorkspase\SpringProgram\bin\beans.xml]: Cannot resolve reference to bean 'hibernateTemplateBean' while setting bean property 'hibernateTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplateBean' defined in file [E:\new project\marsWorkspase\SpringProgram\bin\beans.xml]: Cannot resolve reference to bean 'sfBean' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sfBean' defined in file [E:\new project\marsWorkspase\SpringProgram\bin\beans.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
  </code></pre>