These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: RuntimeException on DAOFactory.instance
PostPosted: Fri Mar 05, 2010 10:27 am 
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?


Top
  
 
 Post subject: Re: RuntimeException on DAOFactory.instance
PostPosted: Thu Oct 06, 2011 4:14 pm 
Newbie

Joined: Thu Oct 06, 2011 4:09 pm
Posts: 1
Did you find a solution for this problem?
I have exactly the same ;-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.