0 Replies Latest reply on Oct 25, 2011 2:22 PM by AJ Hawks

    Trying to get Seam (2.2.1CR2) to manage database connections

    AJ Hawks Newbie

      I am trying to modify a Seam 2.2.1.CR2 application.


      Currently the DAO class creates and closes Connection() objects for each call. I would like Seam to handle the database connection/datasource/session, and either inject them, or allow the DAO to do getInstance() to retrieve them.


      I have been looking at the reference guide, section 9.2.3, thinking I could just create HibernateSessionFactory and HibernateSession components, and retrieve a database connection from them (I am simply calling a stored procedure, I have no need for 99% of Hibernate's features, I just need access to a Connection).


      I added hibernate3-3.2.0.jar and hibernate-annotations-3.1.3.jar, and
      added this to my components.xml:


      <persistence:hibernate-session-factory name="hibernateSessionFactory" cfg-resource-name="hibernate.cfg.xml"/>



      When I deploy, I always get this error:


      org.jboss.seam.InstantiationException: Could not instantiate Seam component: hibernateSessionFactory
           at org.jboss.seam.Component.newInstance(Component.java:2170)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
      ...
      Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.AnnotationConfiguration.setProperty(Ljava/lang/String;Ljava/lang/String;)Lorg/hibernate/cfg/AnnotationConfiguration;
           at org.jboss.seam.persistence.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:114)
           at org.jboss.seam.persistence.HibernateSessionFactory.startup(HibernateSessionFactory.java:79)
           ... 151 more
      



      I've never added hibernate to a project from scratch like this, apologies if I'm missing something obvious. Thanks in advance.