-->
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: Glassfish 3.1 Open Source Edition and Hibernate 3.6.6 Final
PostPosted: Mon Aug 01, 2011 6:22 am 
Newbie

Joined: Mon Aug 01, 2011 5:54 am
Posts: 2
Does Hibernate 3.6.6 Final and Glassfish 3.1 have incompatibilities in bean-validator.jar and validation-api-1.0.0.GA.jar ?

Following scenario:

I start the web application in Eclipse 3.6 with the command "Debug As -> Debug on Server" and i choose the Glassfish Server as Server to run the application with.

When Hibernate tries to build the SessionFactory it throws the Exception

org.hibernate.validator.HibernateValidator cannot be cast to javax.validation.spi.ValidationProvider

The file bean-validator.jar coming with Glassfish Server contains a package with "Hibernate Validator 4.1.0.Final".

The validation-api-1.0.0.GA.jar is put in directory "glassfish3\glassfish\domains\domain1\lib\ext" and is used by "Hibernate Validator 4.1.0.Final".
When i delete the validation-api-1.0.0.GA.jar from directory "glassfish3\glassfish\domains\domain1\lib\ext" i get the exception

java.lang.ClassNotFoundException: javax.validation.Validation

So there must be a dependency between the Hibernate Validator 4.1.0.Final in bean-validator.jar and the validation-api-1.0.0.GA.jar .

But why does Hibernate can't build the SessionFactory and throws the Exception ?


Code:
public class HibernateUtil {

   private static final SessionFactory sessionFactory = buildSessionFactory();
   
   private static SessionFactory buildSessionFactory() {
      
      SessionFactory sessionFactory = null;
      
      try{
         
         sessionFactory = getInitializedConfiguration().buildSessionFactory(); <--- when these method is called the exception is thrown
         
      }catch(HibernateException e) {
         
         System.out.println("");
         e.printStackTrace();
      }
      
      return sessionFactory;
   }

   
//============================ public accessors
   
   public static SessionFactory getSessionFactory() {
      return sessionFactory;
   }
   
   public static Session getCurrentSession() {
      return sessionFactory.getCurrentSession();
   }
   
//============================ private methods   

   private static Configuration getInitializedConfiguration() throws HibernateException {
      
      Configuration configuration = null;
      configuration = new Configuration().configure("/hibernate.cfg.xml");
      return configuration;
   }
}


Top
 Profile  
 
 Post subject: Re: Glassfish 3.1 Open Source Edition and Hibernate 3.6.6 Final
PostPosted: Tue Aug 02, 2011 12:15 pm 
Newbie

Joined: Mon Aug 01, 2011 5:54 am
Posts: 2
solved: there are really incompatibilities with the jars, changing to an earlier version of hibernate (3.4 GA) solved the problem.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.