Bean definition is abstract Error on a Standalone Java application

admin

Administrator
Staff member
Im trying to create a ParentDao that will handle all the connection details for my Standalone Java application.<br>
When I run my program I get the Error below

<blockquote>
Exception in thread "main"
org.springframework.beans.factory.BeanIsAbstractException: Error
creating bean with name 'parentDao': Bean definition is abstract
</blockquote>

What am I doing wrong?
I know its an abstract class I was just following this examples which also used abstract classes. <a href="http://nikojava.wordpress.com/2009/08/29/easy-jdbc-using-spring/#spring-jdbc-design-en" rel="nofollow">abstract ParentDao Class</a> and this one <a href="http://java.dzone.com/articles/dry-your-spring-beans" rel="nofollow">DRY your Spring Bean</a> Im totally lost specially on how to do it on a Standalone application. And where do I initialize the ApplicationContext and how.

Below is my Connection Properties (bean.xml)

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.xsd"&gt;

    &lt;bean id="dataSource" destroy-method="close"
        class="org.apache.commons.dbcp.BasicDataSource"&gt;
        &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
        &lt;property name="url" value="jdbc:oracle:thin:@ipaddress:1521:habagat" /&gt;
        &lt;property name="username" value="username" /&gt;
        &lt;property name="password" value="password" /&gt;
    &lt;/bean&gt;

    &lt;bean id="parentDao" class="com.mercury.dao.ParentDAO" abstract="true"&gt;
        &lt;property name="dataSource" ref="dataSource" /&gt;
    &lt;/bean&gt;
    &lt;bean id="childDao" class="com.mercury.dao.ChildDAOImpl" parent="parentDao"/&gt;        
&lt;/beans&gt;

BELOW IS MY MAIN METHOD

Code:
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext(
        "beans.xml");
ParentDAO parentDao = (ParentDAO) context.getBean("parentDao");
}

AND MY PARENT DAO CLASS

Code:
   public abstract class ParentDAO&lt;T&gt; extends JdbcDaoSupport {

        public abstract void insert(T object) throws Exception;

        public abstract void delete(int id) throws Exception;

        public abstract void update(T object) throws Exception;

        public abstract T select(int id) throws Exception;
}

MY SERVICE

Code:
public class myService {

    ChildDAO childDao;

    public String getChildrenCount() {


        return int totalCount = childDao.getRecordCount();
    }
}