-->
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: Can't build session factory - Error applying BeanValidation
PostPosted: Fri Mar 01, 2013 12:49 am 
Newbie

Joined: Sat Jun 11, 2005 8:35 am
Posts: 14
I am trying to migrate a project that was previously running with Hibernate 3.3.1 to Hibernate 4.1.10. I am running this in Java application mode using a simple test harness to get the basics of the migration worked out.

Here is my configuration file content:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<!-- Database Properties -->
<property name="connection.url">jdbc:db2://myhost.com:5000/mydb</property>

<property name="connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>

<property name="connection.username">xxxxxxx</property>
<property name="connection.password">xxxxxxx</property>
<property name="default_schema">TEST</property>
<property name="generate_statistics">true</property>
<property name="dialect">isc.tools.mfg.omcs.dao.hibernate.dialect.OMCSDB2Dialect</property>
<property name="use_outer_join">true</property>
<property name="jdbc.batch_size">30</property>


<!-- Cache and statistics settings -->
<property name="cache.use_second_level_cache">true</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.region_prefix">omcs</property>
<property name="cache.use_structured_entries">true</property>
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<property name="generate_statistics">true</property>

<property name="connection.usetxapi">true</property>

<!-- Mapping Files -->
<mapping resource="maps/CustomTypes.hbm.xml" />
<mapping resource="maps/Activitylog.hbm.xml" />
...

</session-factory>
</hibernate-configuration>

The exception that I am getting is this:

[ERROR:HibernateDaoImpl ] [getSessionFactory : 2681 ] Exception caught obtaining Hibernate SessionFactory :: [org.hibernate.HibernateException]
org.hibernate.HibernateException: Error applying BeanValidation relational constraints
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:219)
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:126)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:303)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1743)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1781)
at isc.tools.mfg.omcs.dao.hibernate.impl.HibernateDaoImpl.getSessionFactory(HibernateDaoImpl.java:2658)
at isc.tools.mfg.omcs.dao.hibernate.impl.HibernateDaoImpl.getSession(HibernateDaoImpl.java:2563)
at isc.tools.mfg.omcs.dao.hibernate.impl.HibernateDaoImpl.beginTransaction(HibernateDaoImpl.java:265)
at isc.tools.mfg.omcs.processors.UnitOfWorkProcessor.retrieveUnitsByMfgnoIds(UnitOfWorkProcessor.java:5868)
at isc.tools.mfg.omcs.processors.UnitOfWorkProcessor.retrieveUnitByMfgnoId(UnitOfWorkProcessor.java:4777)
at isc.tools.mfg.omcs.hibernate.test.HibernateScaTest.main(HibernateScaTest.java:86)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:208)
... 10 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)
... 15 more
Caused by: javax.validation.ValidationException: Could not create Configuration.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:175)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:50)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:521)
... 16 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:352)
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:173)
... 18 more

This seems to be hooking the Hibernate Validation project functionality - but I didn't think that was required since it is not part of the required libs for the Hibernate project when you download the 4.1.10 zip. Here are the Hibernate related jar files that I have referenced by this project:

antlr-2.7.7.jar
ehcache-core-2.4.3.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.10.Final.jar
hibernate-ehcache-4.1.10.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
javassist-3.15.0-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar

Is there some configuration property that I need to change/add to eliminate this? Or is there a dependency now on Hibernate Core on Hibernate Validation regardless of any configuration settings?

_________________
Regards,

Scott Jacobs
srj@mindspring.com


Top
 Profile  
 
 Post subject: Re: Can't build session factory - Error applying BeanValidation
PostPosted: Thu Mar 14, 2013 10:57 am 
Newbie

Joined: Sat Jun 11, 2005 8:35 am
Posts: 14
I figured out the problem - turns out I had accidentally included both the WAS 8 server runtime and the Eclipse default IDE runtime in the path for the test project I was using - so apparently that was causing a problem with the classes being found as part of the Hibernate initialization. Once I eliminated the WAS 8 server runtime and just used the IDE runtime (since this was a simple standalone Java test application) Hibernate initialized correctly and a simple retrieval I had coded in this test application ran just fine.

_________________
Regards,

Scott Jacobs
srj@mindspring.com


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.