0

I´m trying to save a simple user in my jpa hibernate db. So I have a persistence.xml that I know that works (If I execute a simple test without deploying the gwt app).

The problem is that when I test it with my user interface, the persist method throw me the next error: (I think this is cause Doesn´t find the persistence.xml)

[ERROR] javax.persistence.PersistenceException: [PersistenceUnit: isw2.tasks] Unable to >configure EntityManagerFactory

... bla bla bla

[ERROR] Caused by: org.hibernate.HibernateException: Unable to get the default Bean >Validation factory

... more bla bla bla..

[ERROR] Caused by: java.lang.reflect.InvocationTargetException

... [ERROR] Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory

[ERROR] at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383)

[ERROR] at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109)

.....

[ERROR] Caused by: javax.validation.ValidationException: Unable to find a default provider

[ERROR] at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264)

[ERROR] at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)

[ERROR] at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.ja

This is the method I know that works:

`EntityManagerFactory emf = Persistence .createEntityManagerFactory("isw2.tasks"); em = emf.createEntityManager();

    em.getTransaction().begin();

    em.persist(u);

    em.getTransaction().commit();
    em.clear();
    em.close();

`

And the most usefull for us, my proyect skeleton: (See that the persistence.xml file is there!)

enter image description here

I´m using maven and deploying the web app with the codehaus plugin.

Thanks in advance experts ;)

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
migueloop
  • 525
  • 9
  • 21

1 Answers1

2

The exception message Unable to find a default provider suggests that hibernate cannot find a validation provider.

Is your Hibernate Validator jar on your runtime classpath? Also do note that you need to use Hibernate Validator 4 or later.

Community
  • 1
  • 1
Tahir Akhtar
  • 11,385
  • 7
  • 42
  • 69
  • Oh! It was this!, I was using Hibernate Validator 3.1 instead the last version. Thanks you for your time @Tahir. – migueloop Aug 24 '11 at 22:21