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)
BELOW IS MY MAIN METHOD
AND MY PARENT DAO CLASS
MY SERVICE
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:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@ipaddress:1521:habagat" />
<property name="username" value="username" />
<property name="password" value="password" />
</bean>
<bean id="parentDao" class="com.mercury.dao.ParentDAO" abstract="true">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="childDao" class="com.mercury.dao.ChildDAOImpl" parent="parentDao"/>
</beans>
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<T> 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();
}
}