0 Replies Latest reply on Jul 22, 2010 9:37 AM by Marcin Misiewicz

    Problem with bean validation in jboss 6 M3

    Marcin Misiewicz Newbie



      I recently switched to jboss 6 M3 from M1. Unfortunately after switching the bean validation does not work as it was with M1. Actually nothing happens.

      In the jboss logs there are no validation messages and of course I don't get validation exceptions anymore.

      My entities are packaged into utility module in the ear application. I'm using JPA 2, and JPA 2 specification says that as long as hibernate validation is in the classpath, there is no need to configure bean validation manually and it worked perfectly with M1.

      Of course when I try to validate manually via Validator object, everything works as expected but want to validate entity on persist and update.


      I also tryied to manually configure bean validation in the persistence.xml with no luck.

      Here is my persistence.xml file :


      <?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="smartoffice" transaction-type="JTA">
                     <property name="hibernate.show_sql" value="false"/>
                     <property name="hibernate.hbm2ddl.auto" value="update"/>
                     <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
                     <property name="jboss.entity.manager.factory.jndi.name" value="java:/persistence/smartoffice"/>
                     <property name="javax.persistence.validation.group.pre-persist" value="javax.validation.groups.Default"/>
                     <property name="javax.persistence.validation.group.pre-update" value="javax.validation.groups.Default"/>
                     <property name="javax.persistence.validation.group.pre-remove" value=""/>


      Of course it doesn't work without validation specific properties and validation-mode tag.

      I don't what am I doing wrong. Today when I have cleaned the jboss tmp and work directory, validation worked only for the first time.

      But when I started jboss once again it stopped working properly. Cleaning tmp and work directory is not helpfull anymore.


      Here is the directory listing of my ear application :


      drwxr-xr-x  2 misiek misiek 4096 2010-07-22 12:24 lib
      drwxr-xr-x  2 misiek misiek 4096 2010-07-22 14:00 META-INF
      drwxr-xr-x  4 misiek misiek 4096 2010-07-22 12:24 pl.scentia.smartoffice.businessClient.jar
      drwxr-xr-x  4 misiek misiek 4096 2010-07-22 12:24 pl.scentia.smartoffice.business.jar
      drwxr-xr-x 10 misiek misiek 4096 2010-07-22 12:24 pl.scentia.smartoffice.gui.war
      drwxr-xr-x  5 misiek misiek 4096 2010-07-22 12:24 pl.scentia.smartoffice.persistence.jar
      drwxr-xr-x  4 misiek misiek 4096 2010-07-22 12:24 pl.scentia.smartoffice.proxy.jar
      drwxr-xr-x  5 misiek misiek 4096 2010-07-22 12:24 pl.scentia.smartoffice.security.jar


      As you can see I'm deploying exploded ear and its modules.


      Here is my ear application.xml file :


      <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="smartoffice" version="5">


      I don't know what am I doing wrong ? 


      I'm using sun java on ubuntu 10.04.


      Thanks in advance