-->
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.  [ 4 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  
 
 Post subject: Re: Hibernate 4.1 Unable to build the default ValidatorFactory
PostPosted: Wed Mar 25, 2015 10:59 pm 
Newbie

Joined: Wed Jan 07, 2015 6:26 am
Posts: 3
Hi simonnallen,

I am facing the same issue as you did, I tried to upgrade hibernate (entity-manager, core, validator...) from 3.6.10.Final to 4.1.0.Final and integrate them with Spring 3.2.1.RELEASE. The bundle persistence is deployed to karaf 2.4.1

Here is my pom.xml
Code:
<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate-version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate-version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate.validator-version}</version>
        </dependency>


Code:
        <hibernate-version>4.1.0.Final</hibernate-version>
        <hibernate.validator-version>4.2.0.Final</hibernate.validator-version>
        <hibernate.annotations-version>3.5.6-Final</hibernate.annotations-version>
        <spring-version>3.2.1.RELEASE</spring-version>


and persistence.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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/persistence_2_0.xsd">
   <persistence-unit name="mobilePersistenceUnit" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>     
     
        <class>com.discorp.model.common.Address</class>
        ....
        <properties>
            <property name="hibernate.dialect" value="com.discorp.dialect.JsonPostgreSQLDialect"/>
            <property name="hibernate.show_sql" value="false"/>

            <property name="hibernate.globally_quoted_identifiers" value="false"/>
            <property name="hibernate.generate_statistics" value="true"/>
            <property name="javax.persistence.validation.mode" value="callback,ddl"/>
            <!--<property name="hibernate.cache.region.factory_class" value ="org.hibernate.cache.ehcache.EhCacheRegionFactory"/>-->
            <!--&lt;!&ndash; enable second level cache and query cache &ndash;&gt;-->
            <!--<property name="hibernate.cache.use_second_level_cache" value="true"/>-->
            <!--<property name="hibernate.cache.use_query_cache" value="true"/>-->
            <!--<property name="net.sf.ehcache.configurationResourceName" value="META-INF/myehcache.xml"/>-->
        </properties>
    </persistence-unit>
</persistence>


The stacktrace of the error that I got
Code:
2015-03-26 09:44:24,521 | ERROR | tenderThread-138 | ContextLoaderListener            | 185 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=persistence, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManager' defined in URL [bundle://273.2:0/META-INF/spring/persistence-bundle-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: mobilePersistenceUnit] Unable to build EntityManagerFactory
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)[69:org.springframework.context:3.2.1.RELEASE]
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:922)[69:org.springframework.context:3.2.1.RELEASE]
   at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)[184:org.springframework.osgi.core:1.2.1]
   at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)[184:org.springframework.osgi.core:1.2.1]
   at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[184:org.springframework.osgi.core:1.2.1]
   at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[184:org.springframework.osgi.core:1.2.1]
   at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)[185:org.springframework.osgi.extender:1.2.1]
   at java.lang.Thread.run(Thread.java:745)[:1.7.0_71]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: mobilePersistenceUnit] Unable to build EntityManagerFactory
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:288)[63:org.springframework.orm:3.2.1.RELEASE]
   at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)[63:org.springframework.orm:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)[74:org.springframework.beans:3.2.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)[74:org.springframework.beans:3.2.1.RELEASE]
   ... 14 more
Caused by: org.hibernate.HibernateException: Error applying BeanValidation relational constraints
   at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:219)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:126)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:302)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:88)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_71]
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_71]
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_71]
   at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_71]
   at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:208)[84:com.springsource.org.hibernate.core:4.1.0.Final]
   ... 25 more
Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
   at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:524)
   at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:119)
   ... 30 more
Caused by: javax.validation.ValidationException: Unable to find a default provider
   at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264)
   at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
   at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:521)
   ... 31 more


I am using IntelliJ IDEA an all that libraries are included in classpath already.
Do you have any suggestions for that?

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.