[jboss-jira] [JBoss JIRA] (WFLY-13734) JPA subsystem should fail deployment if ValidationMode.CALLBACK is configured but the BV capability is not present

Yeray Borges Santana (Jira) issues at jboss.org
Thu Aug 6 07:13:00 EDT 2020


    [ https://issues.redhat.com/browse/WFLY-13734?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14360764#comment-14360764 ] 

Yeray Borges Santana commented on WFLY-13734:
---------------------------------------------

I think I misunderstood the point here. [~brian.stansberry], ignore my previous [#comment-14356058]

[~smarlow] My doubt was in relation to the need of adding the {{bean-validation}} Galleon layer to {{jpa}} / {{jpa-distributed}}. CDI is not a requirement to make bean validation to work. I understand we should add {{bean-validation}} Galleon layer as an optional dependency for {{jpa}} / {{jpa-distributed}} Galleon layers. That will allow the users, which are using a JPA application, to get by default the bean validation working for their deployments. 

If the user excludes the {{bean-validation}} Galleon layer from {{jpa}} / {{jpa-distributed}} Galleon layers, the deployment will succeed but bean validation won't work in the application code. 
If the user excludes the {{bean-validation}} Galleon layer from {{jpa}} / {{jpa-distributed}} Galleon layers, and configures JPA with ValidationMode.CALLBACK, the deployment will fail because the persistent provider will thrown an exception.

To sum up, adding the {{bean-validation}} Galleon layer to {{jpa}} / {{jpa-distributed}} Galleon layers will make bean validation work with a JPA application out of the box, which makes sense.

[~smarlow] just wanted to confirm the following, I assume the JPA persistent provider is able to distinguish which ValidationMode has been configured, is this assumption correct?

I'm asking because, looking at the common piece of code dealing with this on PersistenceUnitServiceHandler.java:

{code:java}
if (!ValidationMode.NONE.equals(pu.getValidationMode())) {
           // Get the CDI-enabled ValidatorFactory	                
           if (capabilitySupport.hasCapability("org.wildfly.bean-validation")) {
                    validatorFactory = deploymentUnit.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY);
                }
            }	           
}
{code}

There is no distinction between the value the validatorFactory gets, it will be always null, when we don't have the "org.wildfly.bean-validation" capability and we are using either ValidationMode.CALLBACK or ValidationMode.AUTO. So the persistent provider should know that the configuration is ValidationMode.CALLBACK to throwing an exception.

> JPA subsystem should fail deployment if ValidationMode.CALLBACK is configured but the BV capability is not present
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: WFLY-13734
>                 URL: https://issues.redhat.com/browse/WFLY-13734
>             Project: WildFly
>          Issue Type: Bug
>          Components: JPA / Hibernate
>            Reporter: Brian Stansberry
>            Assignee: Scott Marlow
>            Priority: Major
>             Fix For: No Release
>
>
> This is a follow-on to https://github.com/wildfly/wildfly/pull/13444 / WFLY-13726.  That fix is about applying logic consistently in both places where PersistenceUnitServiceHandler integrates with BV. But I suspect the existing handling isn't correct in the case where ValidationMode.CALLBACK is configured. The javadoc for that enum value says "The persistence provider must perform the lifecycle event validation.  It is an error if there is no Bean Validation provider present in the environment." But I think our handling is ignoring that if the BV capability is not present.



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list