2 Replies Latest reply on Aug 3, 2011 9:38 AM by guinotphil

    Hibernate 3 validation: Unable to find a default provider

    guinotphil Apprentice

      Hello !

       

      I'm trying to deploy an EAR application running on Hibernate 3.

       

      I've been following the steps on https://docs.jboss.org/author/display/AS7/JPA+Reference+Guide by adding a module org.hibernate3 and adding in my persitence.xml:

      <property name="jboss.as.jpa.providerModule" value="org.hibernate3"/>

       

      My module org.hibernate3 contains the following jar and dependencies:

       

      <module xmlns="urn:jboss:module:1.0" name="org.hibernate3">

          <resources>

              <resource-root path="hibernate-core-3.6.6.Final.jar"/>

              <resource-root path="hibernate-entitymanager-3.6.6.Final.jar"/>

              <resource-root path="hibernate-validator-3.1.0.GA.jar"/>

              <resource-root path="hibernate-commons-annotations-3.2.0.Final.jar"/>

              <!-- Insert resources here -->

          </resources>

       

          <dependencies>

              <module name="asm.asm"/>

              <module name="javax.api"/>

              <module name="javax.persistence.api"/>

              <module name="javax.transaction.api"/>

              <module name="javax.validation.api"/>

              <module name="org.antlr"/>

              <module name="org.apache.ant"/>

              <module name="org.apache.commons.collections"/>

              <module name="org.dom4j"/>

              <module name="org.infinispan"/>

              <module name="org.javassist"/>

              <module name="org.jboss.as.jpa.hibernate3"/>

              <module name="org.jboss.logging"/>

              <module name="org.slf4j"/>

          </dependencies>

      </module>

       

       

      My trouble is that when I try to deploy the application I get the following error:

       

      javax.persistence.PersistenceException: [PersistenceUnit: entityManagerFactory] Unable to configure EntityManagerFactory

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:378) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

          at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

          at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

          at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81) [jboss-seam.jar:]

          at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50) [jboss-seam.jar:]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_22]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_22]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_22]

          at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_22]

          at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) [jboss-seam.jar:]

          at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) [jboss-seam.jar:]

          at org.jboss.seam.Component.callComponentMethod(Component.java:2257) [jboss-seam.jar:]

          at org.jboss.seam.Component.callCreateMethod(Component.java:2172) [jboss-seam.jar:]

          at org.jboss.seam.Component.newInstance(Component.java:2132) [jboss-seam.jar:]

          ... 63 more

      Caused by: org.hibernate.HibernateException: Unable to get the default Bean Validation factory

          at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.cfg.Configuration.applyBeanValidationConstraintsOnDDL(Configuration.java:1704) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1654) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1445) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1519) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1100) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:282) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:366) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

          ... 77 more

      Caused by: java.lang.reflect.InvocationTargetException

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_22]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_22]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_22]

          at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_22]

          at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:118) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          ... 86 more

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

          at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          ... 91 more

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

          at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264) [validation-api-1.0.0.GA.jar:]

          at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111) [validation-api-1.0.0.GA.jar:]

          at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:380) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

          ... 92 more

       

       

       

      I've also tried to upgrade hibernate-validator to hibernate-validator-4.2.0.Final.jar + hibernate-validator-legacy-4.0.2.GA.jar, but I'm still getting the same error.

       

      Is there a way to make validation working with Hibernate 3 on JBoss AS 7 ? Or should I disable validation (how?) ?

       

      Thank you very much !

        • 1. Re: Hibernate 3 validation: Unable to find a default provider
          Scott Marlow Master

          What happens if you simply remove or comment out the hibernate-validator-3.1.0.GA.jar in the module.xml? 

          • 2. Re: Hibernate 3 validation: Unable to find a default provider
            guinotphil Apprentice

            Thank you for your reply.

             

            Firstly, if I try and let in my EAR's jboss-deployment-structure.xml the exclusion of org.hibernate.validator, I optain the following error:

             

            java.lang.NoClassDefFoundError: org/hibernate/validator/ClassValidator

                at java.lang.Class.getDeclaredMethods0(Native Method) [:1.6.0_22]

                at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) [:1.6.0_22]

                at java.lang.Class.getDeclaredMethods(Class.java:1791) [:1.6.0_22]

                at org.jboss.seam.Component.initMembers(Component.java:550) [jboss-seam.jar:]

                at org.jboss.seam.Component.<init>(Component.java:244) [jboss-seam.jar:]

                at org.jboss.seam.Component.<init>(Component.java:205) [jboss-seam.jar:]

                at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1186) [jboss-seam.jar:]

                ... 11 more

            Caused by: java.lang.ClassNotFoundException: org.hibernate.validator.ClassValidator from [Module "deployment.EAR_Project.ear.jboss-seam.jar:main" from Service Module Loader]

                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:358)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:330)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:307)

                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)

                ... 18 more

             

             

            Without the exclusion, so with an implicit dependency to hibernate validation 4.2 (be aware that I also added hibernate-validator-legacy-4.0.2.GA.jar to the org.hibernate.validator module), I optain the following error:

             

            java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/XMember

                at java.lang.Class.getDeclaredConstructors0(Native Method) [:1.6.0_22]

                at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) [:1.6.0_22]

                at java.lang.Class.getConstructor0(Class.java:2699) [:1.6.0_22]

                at java.lang.Class.getDeclaredConstructor(Class.java:1985) [:1.6.0_22]

                at org.hibernate.cfg.Configuration.applyHibernateValidatorLegacyConstraintsOnDDL(Configuration.java:1669) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1653) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1445) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1519) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1100) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:282) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:366) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

                at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81) [jboss-seam.jar:]

                at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50) [jboss-seam.jar:]

                ... 22 more

            Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.XMember from [Module "org.hibernate.validator:main" from local module loader @12401369 (roots: C:\DEV\jboss-as-7.1.0.Alpha1-SNAPSHOT\modules)]

                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:358)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:330)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:307)

                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)

                ... 40 more

             

             

            Because the module has no access to the hibernate3 classes.

             

            I haven't managed to found how to make this work, except by adding a depency to hibernate 3 in org.hibernate.validator's module.xml (which I think is not good)

             

            Well, now I got the folowing error :

             

            javax.persistence.PersistenceException: [PersistenceUnit: entityManagerFactory] Unable to build EntityManagerFactory

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]

                at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81) [jboss-seam.jar:]

                at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50) [jboss-seam.jar:]

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_22]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_22]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_22]

                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_22]

                at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) [jboss-seam.jar:]

                at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) [jboss-seam.jar:]

                at org.jboss.seam.Component.callComponentMethod(Component.java:2257) [jboss-seam.jar:]

                at org.jboss.seam.Component.callCreateMethod(Component.java:2172) [jboss-seam.jar:]

                at org.jboss.seam.Component.newInstance(Component.java:2132) [jboss-seam.jar:]

                ... 63 more

            Caused by: org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available

                at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:106) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:152) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870) [hibernate-core-3.6.6.Final.jar:3.6.6.Final]

                at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906) [hibernate-entitymanager-3.6.6.Final.jar:3.6.6.Final]