1 Reply Latest reply on Feb 29, 2012 8:31 AM by naeem.ally

    Hibernate Validator not found

    naeem.ally

      Hi

       

      I have a spring+jpa+hibernate web project, I'm using apache cxf as well.

       

      I've been struggling to get the hibernate validator jar loaded on the class path but nothing that i've tried seems to work.

      I get a valid error from spring, I need an implementation of javax.validation.Validator.

       

      {quote}

      No matching bean of type [javax.validation.Validator] found for dependency: expected at least 1 bean which qualifies

      {quote}

       

      Below is hopefully some useful debug information.

       

      I removed the spring and hibernate jars from my war but that doesn't seem to make a difference.

      Is there anything I'm missing?

       

      I created a spring module

      modules/org/springframework/spring/main/module.xml

      {code:xml}

      <module xmlns="urn:jboss:module:1.1" name="org.springframework.spring">

       

       

          <resources>

              <resource-root path="spring-context.jar"/>

              <resource-root path="spring-beans.jar"/>

              <resource-root path="spring-aop.jar"/>

              <resource-root path="spring-asm.jar"/>

              <resource-root path="spring-core.jar"/>

              <resource-root path="spring-expression.jar"/>

              <resource-root path="spring-tx.jar"/>

              <resource-root path="spring-jms.jar"/>

              <resource-root path="spring-web.jar"/>

              <resource-root path="spring-webmvc.jar"/>

              <resource-root path="aopalliance-1.0.jar"/>

          </resources>

       

       

          <dependencies>

              <module name="javax.api" />

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

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

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

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

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

              <module name="javax.servlet.jsp.api" />       

              <module name="javax.xml.ws.api" />

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

              <module name="org.hibernate.validator" services="import">

                  <imports>

                      <include path="META-INF**" />

                      <include path="org**" />

                  </imports>

              </module>

          </dependencies>

      </module>

      {code}

       

       

      I created a hibernate 3 module,

      modules/org/hibernate/3/module.xml

      {code:xml}

      <module xmlns="urn:jboss:module:1.0" name="org.hibernate" slot="3">

       

       

                <resources>

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

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

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

                </resources>

                <dependencies>

                    <module name="org.jboss.as.jpa.hibernate" slot="3"></module>

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

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

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

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

                    <module name="org.antlr"></module>

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

                    <module name="org.dom4j"></module>

                    <module name="org.infinispan"></module>

                    <module name="org.javassist"></module>

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

                    <module name="org.slf4j"></module>

                  <module name="org.hibernate.validator" services="import">

                  <imports>

                          <include path="META-INF**" />

                          <include path="org**" />

                      </imports>

                  </module>

       

       

                </dependencies>

      </module>

      {code}

       

      This is what my jboss-deployment-structure.xml looks like

       

      {code:xml}

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

                <deployment>

                          <exclusions>

                                    <!-- Exclude container version of hibernate. By default its v4, we want bundled v3 loaded -->

                                    <module name="org.hibernate" slot="main" />

                          </exclusions>

                          <dependencies>

                  <module name="org.hibernate" services="import" slot="3" />

                  <module name="org.hibernate.validator" services="import">

                      <imports>

                          <include path="META-INF**" />

                          <include path="org**" />

                      </imports>

                  </module>

                  <module name="org.springframework.spring" services="import">

                      <imports>

                          <include path="META-INF**" />

                          <include path="org**" />

                      </imports>

                  </module>          

                                    <!-- Add dependencies, since in 'pom.xml' we exclude transitive dependencies from

                                              reactor, we need to add following modules, to make application work properly -->

                                    <!-- NOTE: module name does not always correspond to maven artifact ID -->

                                    <!-- Add dependency on commons.logging -->

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

                                    <!-- Add dependency on commons.collections -->

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

                                    <!-- Add dependency on log4j -->

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

                                    <!-- Add dependency on dom4j -->

                                    <module name="org.dom4j" />

                                    <!-- Add dependency on slf4j -->

                                    <module name="org.slf4j" />

                                    <!-- Add dependency on antlr -->

                                    <module name="org.antlr" />

                                    <!-- Add dependency on asm -->

                                    <module name="asm.asm" />

                                    <!-- Add dependency on javassist -->

                                    <module name="org.javassist" />

                  <!-- Add dependency on cxf -->

                  <module name="org.apache.cxf" export="true" services="import">

                      <imports>

                          <include path="**" />

                      </imports>

                  </module>

                          </dependencies>

                </deployment>

      </jboss-deployment-structure>

      {code}

       

      I'm not sure if i need the manifest and jboss-deployment-structure

      META-INF/MANIFEST.MF

      {quote}

      Manifest-Version: 1.0

      Dependencies: org.slf4j, org.apache.cxf services, org.springframework.spring, org.hibernate, org.hibernate.validator services

      Class-Path:

      {quote}

       

      {quote}

      10:58:26,494 INFO  [org.hibernate.cfg.Configuration] (MSC service thread 1-3) Hibernate Validator not found: ignoring

      10:58:26,528 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-3) Hibernate Validator 4.2.0.Final

      10:58:26,543 DEBUG [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-3) Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver

      10:58:26,545 DEBUG [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-3) Instantiated JPA aware TraversableResolver of type org.hibernate.validator.engine.resolver.JPATraversableResolver.

      10:58:26,550 DEBUG [org.hibernate.validator.xml.ValidationXmlParser] (MSC service thread 1-3) Trying to load META-INF/validation.xml for XML based Validator configuration.

      10:58:26,552 DEBUG [org.hibernate.validator.xml.ValidationXmlParser] (MSC service thread 1-3) No META-INF/validation.xml found. Using annotation based configuration only

       

       

       

       

      10:58:26,755 DEBUG [org.hibernate.cfg.Configuration] (MSC service thread 1-3) Legacy Validator not present in classpath, ignoring event listener registration

      10:58:26,760 DEBUG [org.hibernate.cfg.search.HibernateSearchEventListenerRegister] (MSC service thread 1-3) Search not present in classpath, ignoring event listener registration.

      10:58:26,761 INFO  [org.hibernate.cfg.search.HibernateSearchEventListenerRegister] (MSC service thread 1-3) Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.

      {quote}

       

       

      Am i missing anything obvious?

       

      Thanks