Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Hibernate 4.1 Unable to build the default ValidatorFactory
PostPosted: Thu Mar 01, 2012 8:56 pm 
Newbie

Joined: Thu Mar 01, 2012 8:48 pm
Posts: 2
OK trying to upgrade from Hibernate 3.6.10 to 4.1

I am using Hibernate in a desktop java swing application. All works fine in 3.6.10. But after I upgrade to 4.1 the EntityManagerFactory fails to be created. The error I get with <validation-mode>CALLBACK</validation-mode>
is:

Unable to build the default ValidatorFactory

if I change this to
<validation-mode>NONE</validation-mode>
The error I get is:

Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]

Any idea of the problem ???

Thanks

Heres my test method:

@Test
public void testGetEntityManager() {
EntityManager entityManager = null;
try {
EntityManagerFactory factory;
// Fails on the next line
factory = Persistence.createEntityManagerFactory("dbresource");
entityManager = factory.createEntityManager();
entityManager.getTransaction().begin();
entityManager.getTransaction().commit();

} catch (RuntimeException re) {
entityManager.getTransaction().rollback();
throw re;
} finally {
entityManager.close();
}
}

heres my persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_2_0.xsd"
version="2.0">
<persistence-unit name="dbresource" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- My simple class -->
<class>org.trade.persistent.dao.Contract</class>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<validation-mode>CALLBACK</validation-mode>
<properties>
<property name="hibernate.connection.driver_class" value="org.gjt.mm.mysql.Driver" />
<property name="hibernate.connection.password" value="ledzepplin" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/tradeprod" />
<property name="hibernate.connection.username" value="trader" />
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.default_schema" value="tradeprod" />
<property name="hibernate.max_fetch_depth" value="5" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.current_session_context_class" value="thread" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.use_sql_comments" value="false" />

<property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="60" />
<property name="hibernate.c3p0.min_size" value="1" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="5" />
<property name="hibernate.c3p0.acquireRetryAttempts" value="1" />
<property name="hibernate.c3p0.acquireRetryDelay" value="250" />
<property name="hibernate.c3p0.max_statements" value="50" />
</properties>
</persistence-unit>
</persistence>

here whats in my class path:
antlr-2.7.7.jar
javassist-3.15.0-GA.jar
c3p0-0.9.1.jar
hibernate-c3p0-4.1.0.Final.jar
hibernate-core-4.1.0.Final.jar
hibernate-entitymanager-4.1.0.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
commons-collections-3.2.1.jar
dom4j-1.6.1.jar
ejb-api-3.0.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
jboss-logging-3.1.0.CR2.jar
hibernate-validator-annotation-processor-4.2.0.Final.jar
validation-api-1.0.0.GA.jar
junit-4.8.1.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
log4j-1.2.16.jar
mysql-connector-java-5.1.18.jar
+ jdk1.7_02


Top
 Profile  
 
 Post subject: Re: Hibernate 4.1 Unable to build the default ValidatorFactory
PostPosted: Sun Mar 04, 2012 12:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 11, 2009 2:26 am
Posts: 29
if you want to use Bean Validation(<validation-mode>CALLBACK</validation-mode>), you need Hibernate Validator in your classpath, NOTE: hibernate-validator-annotation-processor-4.2.0.Final.jar is a dev time tool for check if you placed wrong Constraint on improper place

i may need stacktrace (and mappings) to identify the second error


Top
 Profile  
 
 Post subject: Re: Hibernate 4.1 Unable to build the default ValidatorFactory
PostPosted: Mon Mar 05, 2012 4:56 pm 
Newbie

Joined: Thu Mar 01, 2012 8:48 pm
Posts: 2
stliu wrote:
if you want to use Bean Validation(<validation-mode>CALLBACK</validation-mode>), you need Hibernate Validator in your classpath, NOTE: hibernate-validator-annotation-processor-4.2.0.Final.jar is a dev time tool for check if you placed wrong Constraint on improper place

i may need stacktrace (and mappings) to identify the second error


Ok I added the hibernate-validator-4.2.0.Final.jar to the class path and that fixed the problem. The other exception was related to an application jar that was missing.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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.