0 Replies Latest reply on Feb 11, 2006 2:52 PM by M R

    Error  with Hibernante

    M R Newbie

      I'm trying to use Hibernate (3.1) with JBoss (4.0.3) on a postrgesql database (8.1). I've got this error :

      19:27:45,496 INFO [STDOUT] org.hibernate.MappingException: An AnnotationConfiguration instance is required to use
      at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1427)
      at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1382)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1363)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1339)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1259)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1245)
      at util.HibernateUtil.(HibernateUtil.java:20)
      at site.SiteInternetManager.update(SiteInternetManager.java:35)
      at site.SiteInternet.InitialiseSiteCamping3Pages(SiteInternet.java:79)
      at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:52)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      ....

      I tried a lot of things but I don't understant why Hibernate ask
      for the "AnnotationConfiguration". Can anyone help me ?
      (Sorry for my english).

      I join some files :

      My hibernate.cfg.xml is like that
      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      <hibernate-configuration>
      <session-factory>
      true
      org.postgresql.Driver
      jdbc:postgresql://localhost:5432/GestionClient
      postgres
      aurore27
      org.hibernate.dialect.PostgreSQLDialect
      true


      update










      </session-factory>

      </hibernate-configuration>


      My HibernateUtil.java :

      import org.hibernate.HibernateException;
      import org.hibernate.Session;
      import org.hibernate.SessionFactory;
      import org.hibernate.cfg.Configuration;
      /**
      * Classe de gestion des sessions Hibernate.
      *
      */
      public class HibernateUtil {

      // private static Log log = LogFactory.getLog(HibernateUtil.class);

      private static final SessionFactory sessionFactory;

      static {
      try {
      // Create the SessionFactory
      sessionFactory = new Configuration().configure().buildSessionFactory();
      } catch (Throwable ex) {
      //log.error("Initial SessionFactory creation failed.", ex);
      //ex.printStackTrace();
      throw new ExceptionInInitializerError(ex);
      }
      }

      public static final ThreadLocal session = new ThreadLocal();

      public static Session currentSession() throws HibernateException {
      Session s = (Session) session.get();
      // Open a new Session, if this Thread has none yet
      if (s == null) {
      s = sessionFactory.openSession();
      session.set(s);
      }
      return s;
      }

      public static void closeSession() throws HibernateException {
      Session s = (Session) session.get();
      session.set(null);
      if (s != null)
      s.close();
      }
      }