0 Replies Latest reply on Oct 2, 2007 2:38 AM by Carlos Cotelo

    hibernate annotations and session factory:

    Carlos Cotelo Newbie

      I have this configuration in my webapp:

      The DAO layer:

      <!-- Hibernate SessionFactory -->
       <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
       <property name="dataSource" ref="dataSource"/>
       <property name="configurationClass">
       <value>org.hibernate.cfg.AnnotationConfiguration</value>
       </property>
       <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
       <property name="hibernateProperties">
       <value>
       hibernate.dialect=${hibernate.dialect}
       hibernate.query.substitutions=true 'Y', false 'N'
       </value>
       </property>
       </bean>
      <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
       <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory"/>
       </bean>
      
       <bean id="abstractDao" abstract="true">
       <property name="sessionFactory" ref="sessionFactory"/>
       </bean>
      



      and then i reference the sessionFactory when it's needed.
      I use annotations and not hibernate validation, when i run my application in another web server, there are no problems, but in jboss, the next exception allways occurs:

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [jar:file:/C:/java/jboss-4.0.3SP1/server/default/tmp/deploy/tmp1447mamba-webapp-1.0-M1-SNAPSHOT-exp.war/WEB-INF/lib/mamba-core-1.0-M1-SNAPSHOT.jar!/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener
      Caused by:
      java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener
       at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:783)
      


      what's the reason of this problem? i don't like to use hibernate annotations, i'm using spring modules validation annotations, i think that jboss don't make nothing more than tomcat in this case.
      Can someone help me?
      Thanks.