10 Replies Latest reply on Jan 17, 2014 12:20 PM by antlia

    Disabling Bean Validation Hibernate 4.2.7

    antlia

      Hi to all,

       

      I've just migrated from JBoss AS 7.1.1 final, which has Hibernate 4.0.1, to JBoss EAP 6.2.0 which has Hibernate 4.2.7, and I'm experimenting a big issue.

       

      For disabling Hibernate Validation, with AS 7.1.1, it was sufficient to add the tag <validation-mode>NONE</validation-mode> to the persistence.xml file in my EJB project.

       

      In JBoss EAP 6.2.0 this tag isn't working anymore, and the beans are validated by Hibernate.

       

      I've also tried to substitute <validation-mode> tag with <property name="javax.persistence.validation.mode" value="none"/>, but this is not working too.

       

      Can someone tell me how to disable hibernate validation with this version of hibernate (and JBoss)?

       

      Thanks,

      Antlia

        • 1. Re: Disabling Bean Validation Hibernate 4.2.7
          smarlow

          Hi Antlia,

           

          Can you enable TRACE logging for org.jboss.as.jpa, start the app server and attach the standalone/log/server.log output for the range from deployment start to end (or from the app server console).

           

          Documentation for enabling TRACE logging is here.

           

          Scott

          • 2. Re: Re: Disabling Bean Validation Hibernate 4.2.7
            antlia

            Hi Scott, i followed your suggestions, this is the server's log.

             

            Thank you for your support!

             

            Antlia

            • 3. Re: Re: Disabling Bean Validation Hibernate 4.2.7
              smarlow

              What is the Reapp-0.1-dev.ear/lib/validation-api-1.0.0.GA-sources.jar jar?  Have you tried removing that?

               

              The trace output shows that "javax.persistence.validation.factory" is not being passed into Hibernate which is good.  Which leaves me with wondering if its this validation-api jar.  I'm not sure why it wasn't a problem before and is now for you.

              • 4. Re: Disabling Bean Validation Hibernate 4.2.7
                antlia

                I've just repackaged my ear without the validation-api jar, but the problem is still there...the validation is still active...

                • 5. Re: Re: Disabling Bean Validation Hibernate 4.2.7
                  smarlow

                  Do you have a validation exception with call stack that you could post?  That might give us some clue as to how the Hibernate Validator is being included with the deployment.

                   

                  Do you have a MANIFEST.MF file in your deployment?  If yes, could you show us the contents.

                   

                  Do you have a jboss-deployment-structure.xml file in your deployment, if yes, could you show us the contents.

                  • 6. Re: Re: Re: Disabling Bean Validation Hibernate 4.2.7
                    antlia

                    Hi Scott,

                     

                    I've attached all the content you requested me to this message.

                     

                    - stackTrace.log is the exception that Hibernate is throwing me

                     

                    Since in my application there are more MANIFEST.MF files, I've added all of them, numerated.

                     

                    Many Thanks,

                     

                    Antlia

                    • 7. Re: Re: Re: Re: Disabling Bean Validation Hibernate 4.2.7
                      smarlow

                      The attached exception is not coming from Hibernate Validator, its directly from Hibernate ORM.  Hibernate is complaining about apartmentNumber.

                       

                      Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: it.antlia.common.model.Address.apartmentNumber

                      16:15:44,322 ERROR [stderr] (ajp-/192.168.2.95:8259-2)     at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:103)

                      16:15:44,322 ERROR [stderr] (ajp-/192.168.2.95:8259-2)     at org.hibernate.action.internal.AbstractEntityInsertAction.nullifyTransientReferencesIfNotAlready(AbstractEntityInsertAction.java:132)

                       

                      The error sounds wrong to me, as I would expect apartmentNumber to be nullable.  Does this help?

                      1 of 1 people found this helpful
                      • 8. Re: Re: Re: Re: Disabling Bean Validation Hibernate 4.2.7
                        antlia

                        Hi Scott,

                        yes the apartmentNumber field is marked as @NotNull, but  I'm wondering why, if this exception is thrown by Hibernate ORM layer, in version 4.0.2 disabling the validation with the above-mentioned tag, it is not thrown anymore and everything works fine.

                        Maybe it's a bug on Hibernate 4.0.2 core?

                         

                        Second question, is there an escape to this exception which does not require the removal of the @NotNull annotation?

                        • 9. Re: Re: Re: Re: Re: Disabling Bean Validation Hibernate 4.2.7
                          smarlow

                          Second question, is there an escape to this exception which does not require the removal of the @NotNull annotation?

                          Yes, try setting persistence unit property "hibernate.check_nullability" to false (<property name="hibernate.check_nullability" value="false" />).

                           

                          Maybe it's a bug on Hibernate 4.0.2 core?

                           

                          I'm not sure exactly.  It looks "hibernate.check_nullability" defaults to true unless the Hibernate Validator is accessible and enabled (set to AUTO or CALLBACK).  Try the "hibernate.check_nullability" setting and see if that helps.

                          • 10. Re: Disabling Bean Validation Hibernate 4.2.7
                            antlia

                            Hi Scott,

                             

                            setting the property you told me:

                            <property name="hibernate.check_nullability" value="false" />

                             

                             

                            solved the problem, no exception is thrown.

                             

                            Many Thanks for your support!

                            Best Regards,

                             

                            Antlia