I am getting the following error
Caused by: java.lang.RuntimeException: Couldn't create DAOFactory: class com.hibernate.dao.HibernateDAOFactory
at com.hibernate.dao.interfaces.DAOFactory.instance(DAOFactory.java:37)
when executing
Code:
public static DAOFactory instance(Class<?> factory) {
try {
log.debug("Creating concrete DAO factory: " + factory);
return (DAOFactory) factory.newInstance();
}
catch (Exception ex) {
throw new RuntimeException("Couldn't create DAOFactory: " + factory);
}
}
Code:
public abstract class DAOFactory {
private static Logger log = Logger.getLogger(DAOFactory.class);
/**
* Creates a standalone DAOFactory that returns unmanaged DAO beans for use
* in any environment Hibernate has been configured for. Uses
* HibernateUtil/SessionFactory and Hibernate context propagation
* (CurrentSessionContext), thread-bound or transaction-bound, and
* transaction scoped.
*/
public static final Class<HibernateDAOFactory> HIBERNATE = HibernateDAOFactory.class;
/**
* Factory method for instantiation of concrete factories.
*/
public static DAOFactory instance(Class<?> factory) {
try {
log.debug("Creating concrete DAO factory: " + factory);
return (DAOFactory) factory.newInstance();
}
catch (Exception ex) {
throw new RuntimeException("Couldn't create DAOFactory: " + factory);
}
}
//========================================================================
// DAO INTERFACES
//========================================================================
....
}
Code:
public class HibernateDAOFactory extends DAOFactory {
private GenericHibernateDAO<?, ?> instantiateDAO(Class<?> daoClass) {
try {
GenericHibernateDAO<?, ?> dao = (GenericHibernateDAO<?, ?>)daoClass.newInstance();
dao.setSession(getCurrentSession());
return dao;
}
catch (Exception ex) {
throw new RuntimeException("Can not instantiate DAO: " + daoClass,
ex);
}
}
protected Session getCurrentSession() {
return HibernateUtil.getSessionFactory().getCurrentSession();
}
@Override
...
}
The code is contained in an Eclipse EJB project...deployed as an ear on jboss 4.2.3
Java version is 1.5
The Hibernate classes and the EJB's which use them are in separate source folders
The EJB folder contains persistence.xml
The Hibernate folder contains c3p0.properties and hibernate.cfg.xml
What is causing this exception?