Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6666477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:49:58+00:00 2026-05-26T02:49:58+00:00

I have a JSF 2.0/Servlet 3.0 Web application using hibernate with a connection pooled

  • 0

I have a JSF 2.0/Servlet 3.0 Web application using hibernate with a connection pooled data source on glassfish 3.
I tried using the DAO pattern as described in this tutorial:
GenericDataAccessObjects
I am also using the OpenSessionView pattern using the HibernateSessionRequestFilter as described here: OpenSessionInView
The relevant parts of my hibernate config:

<property name="hibernate.current_session_context_class">jta</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.SunONETransactionManagerLookup</property>

The DAO interfaces and implementations seem to work fine but the factory is not able to instantiate the DAOs. If I instantiate them manually in my ManagedBean:

profileDao = new ProfileDAOHibernate();
profileDao.setSession(HibernateUtil.getSessionFactory().getCurrentSession());

But using the factory:

factory = DAOFactory.instance(DAOFactory.HIBERNATE);
profileDao = factory.getProfileDAO();

fails with RuntimeException:

SCHWERWIEGEND: java.lang.InstantiationException: model.dao.interfaces.ProfileDAO
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at model.dao.factory.hibernate.HibernateDAOFactory.instantiateDAO(HibernateDAOFactory.java:87)
at model.dao.factory.hibernate.HibernateDAOFactory.getProfileDAO(HibernateDAOFactory.java:62)
at controller.admin.ProfileController.<init>(ProfileController.java:73)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)

the end:

SCHWERWIEGEND: ava:357)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at appHelper.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)

The HibernateDAOFactory:

// getters for the DAO
@Override
public ProfileDAO getProfileDAO() {
    return (ProfileDAO)instantiateDAO(ProfileDAO.class);
}
//...
private GenericHibernateDAO instantiateDAO(Class daoClass) {
    try {
        GenericHibernateDAO dao = (GenericHibernateDAO)daoClass.newInstance();
        dao.setSession(getCurrentSession());

        return dao;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException("Can not instantiate DAO: " + daoClass, ex);
    }
}

// You could override this if you don't want HibernateUtil for lookup
protected Session getCurrentSession() {
    return HibernateUtil.getSessionFactory().getCurrentSession();
}

The DAOFactory:

public static final Class HIBERNATE = model.dao.factory.hibernate.HibernateDAOFactory.class;

/**
 * Factory method for instantiation of concrete factories.
 */
public static DAOFactory instance(Class factory) {
    try {
        return (DAOFactory)factory.newInstance();
    } catch (Exception ex) {
        throw new RuntimeException("Couldn't create DAOFactory: " + factory);
    }
}

// DAO Interfaces
public abstract ProfileDAO getProfileDAO();

Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:49:58+00:00Added an answer on May 26, 2026 at 2:49 am

    Here,

    return (ProfileDAO)instantiateDAO(ProfileDAO.class);
    

    you’re trying to instantiate an abstract class. This is the same as you would be doing

    profileDao = new ProfileDAO();
    

    This is not possible. You need to instantiate a concrete class.

    return (ProfileDAO)instantiateDAO(ProfileDAOHibernate.class);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a JSF web application. I use Beans as Spring Beans (not JSF
i have developed an application using jsf 1.2. it worked fine with apache tomcat
We have JSF web application that generates XLS file and gives user link to
I have web application wich uses jsf 2.0 and spring 3.0 The problem is
I've got a fairly simple web application deployed in GlassFish 3.0.1. I'm using regular
I have an error page error.jsf mentioned in the web.xml : <error-page> <exception-type>javax.faces.application.ViewExpiredException</exception-type> <location>/viewExpired.jsp</location>
I have a JSF application that uses mostly Richfaces. I would like to introduce
I have a JSF web client and a Java client that both use the
I have a JSF application with several major components and a component tree under
Ok simple question. I have a JSF application, containing a login page. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.