[bv-dev] Bean Validation 2.0 Early Draft: Web Container Clarification Request

Marco Molteni moltenma at gmail.com
Mon Mar 20 19:09:48 EDT 2017


WebLogic, according to the documentation, supports WEB-INF/validation.xml
http://docs.oracle.com/cd/E24329_01/web.1211/e24368/overview.htm#WLPRG715 <http://docs.oracle.com/cd/E24329_01/web.1211/e24368/overview.htm#WLPRG715>

'Validation descriptors are named validation.xml and are packaged in the META-INF directory, except for Web modules, where the descriptor is packaged in the WEB-INF directory.'


> Am 20.03.2017 um 17:29 schrieb Marco Molteni <moltenma at gmail.com>:
> 
> TomEE: there was a debate around this problem (where to put the validation.xml) in the BVal mailing list (https://www.mail-archive.com/dev@bval.apache.org/msg00361.html <https://www.mail-archive.com/dev@bval.apache.org/msg00361.html>).
> 
> I quickly checked the sources of Glassfish RI (via Payara) and threre is an old TODO (waiting end of the discussions around BV) in the code that creates the default configuration for BV.
> In WAS I found (in the doc, only quick look) a reference only to META-INF/persistence.xml
> 
> I start to think that the support for WEB-INF is more an exception than the rule.
> 
> I agree that there is a lot of confusion around: META-INF, WEB-INF and 'WEB-INF/classes/META-INF' (http://stackoverflow.com/questions/8701482/bean-validation-validation-xml-ignored <http://stackoverflow.com/questions/8701482/bean-validation-validation-xml-ignored>).
> 
> Happy to help or investigate more if needed.
> 
> 
> 
> 
> 
> On Mon, Mar 20, 2017 at 4:51 PM, Gunnar Morling <gunnar at hibernate.org <mailto:gunnar at hibernate.org>> wrote:
> 2017-03-20 13:24 GMT+01:00 Marco Molteni <moltenma at gmail.com <mailto:moltenma at gmail.com>>:
> @Gunnar
> 
> > You seem to suggest that a container somehow may make it that WEB-INF/validation.xml is exposed as META-INF/validation.xml to the BV provider. That may theoretically be doable, but I don't think it's intended or suggested by the EE spec.
> Some Java EE containers implemented this solution. If it's a custom hack or their interpretation of the spec ... I don't know.
> 
> Do you know which containers support this? 
> 
> > My current inclination is to suggest exactly that to the Java EE leads,
> A clarification is welcome :)
> 
> Thanks
> 
> On Mon, Mar 20, 2017 at 12:34 PM, Gunnar Morling <gunnar at hibernate.org <mailto:gunnar at hibernate.org>> wrote:
> Hi,
> 
> Thanks for bringing up this issue, Nathan.
> 
> The Bean Validation spec expects the file to be at META-INF/validation.xml, no matter what type of application it is. I'll need to dig a bit deeper why the platform spec mentions WEB-INF/validation.xml.
> 
> > the TCK uses the WEB-INF/validation.xml location
> 
> Do you have a pointer to this usage? Please send it to me off-list if it's somewhere within the EE TCK. The BV TCK itself uses META-INF/validation.xml.
> 
> > Therefore, I'd expect a lot of users in the field to be using the WEB-INF location
> 
> I just tried WEB-INF/validation.xml in a plain WAR as well as a WAR within an EAR, and it wouldn't be applied either way (testing the BV reference implementation). Do you have a test case which shows successful usage of WEB-INF/validation.xml?
> 
> > Otherwise, the JavaEE Platform spec could be changed to no longer state WEB-INF/validation.xml
> 
> My current inclination is to suggest exactly that to the Java EE leads, as it seems like a glitch and I can't see how it'd ever work with the RI. But I'll synch with Emmanuel (former BV lead) to make sure I'm not missing a piece.
> 
> @Marco,
> 
> > The implementation of 'WEB-INF/validation.xml' for the web components and its 
> > integration with Bean Validation is the full responsibility (EE.5.16.2) of the Java EE 
> > Product Provider that declares it 
> 
> You seem to suggest that a container somehow may make it that WEB-INF/validation.xml is exposed as META-INF/validation.xml to the BV provider. That may theoretically be doable, but I don't think it's intended or suggested by the EE spec.
> 
> Specifically, section EE.5.16 deals with the "application client container" property which the container must set depending on where this app is running (ACC vs. web/EJB container). It's not related to the retrieval of BV deployment descriptors.
> 
> --Gunnar
> 
> 
> 2017-03-17 20:03 GMT+01:00 Marco Molteni <moltenma at gmail.com <mailto:moltenma at gmail.com>>:
> Hi Nathan,
> 
> I agree that can be confusing for the developers that read the two documents but the specification of BV is, IMHO, consistent:
> 
> 1.2. Specification Goals:  'The validation API developed by this JSR is not intended for use in any one tier or programming model. It is specifically not tied to either the web tier or the persistence tier'.
> 
> And the JavaEE spec version 7 (and 8) :
> 'EE.5.16.2 Java EE Product Provider’s Responsibilities
> The Java EE Product Provider is responsible for providing the correct application client container property as required by this specification.'
> 
> 
> 'EE.5.17.1 Application Component Provider’s Responsibilities
> [...] The Application Component Provider may customize the ValidatorFactory and (indirectly) Validator instances by including a Bean Validation deployment descriptor inside a specific module of the application.'
> 
> 'EE.5.17.2 Java EE Product Provider’s Responsibilities
> [...] These objects must be used to configure the default ValidatorFactory available at java:comp/ValidatorFactory in accordance with the bootstrapping APIs described by the Bean Validation specification. [...]'
> 
> 
> The implementation of 'WEB-INF/validation.xml' for the web components and its integration with Bean Validation is the full responsibility (EE.5.16.2) of the Java EE Product Provider that declares it .
> The Bean Validation doesn't have to worry (or know) about the existence of a web component or a web configuration directory, it's out of its scope.
> The correct configuration and communication between these (Web and BC) and other components is regulated by the container (EE.2.4).
> 
> The documents are (maybe) confusing but correct, in my opinion.
> 
> Regards
> 
> Marco
>  
> 
>> Am 15.03.2017 um 17:39 schrieb Nathan Mittlestat <nmittles at gmail.com <mailto:nmittles at gmail.com>>:
>> 
>> Hi All,
>> 
>> One area I'd like to see a clarification on in the spec is around the location of the validation.xml in a JavaEE web container environment.  The Bean Validation spec indicates the validation.xml is always at META-INF/validation.xml.  The JavaEE Platform spec states WEB-INF/validation.xml should be used for web modules. The entire Bean Validation spec has no mention of web modules, and seems to mainly focus on JavaSE.  However, it does mention integration points such as CDI and JAX-RS, so I don't think it would be out of line to clarify in the Bean Validation spec for web modules.  Otherwise, the JavaEE Platform spec could be changed to no longer state WEB-INF/validation.xml, but previous JavaEE versions already include this, and the TCK uses the WEB-INF/validation.xml location. Therefore, I'd expect a lot of users in the field to be using the WEB-INF location.
>> 
>> The Bean Validation spec has the following section (page 206):
>> Unless explicitly ignored by calling Configuration.ignoreXMLConfiguration(), a Configuration takes into
>> account the configuration available in META-INF/validation.xml. This configuration file is optional but
>> can be used by applications to refine some of the Bean Validation behavior. If more than one META-
>> INF/validation.xml file is found in the classpath, a ValidationException is raised.
>> 
>> In contrasts the JavaEE Platform spec has (page 127 of JavaEE 7):
>> In order to customize the returned ValidatorFactory, an EJB, web or
>> application client module may specify a Bean Validation XML deployment
>> descriptor. The name of the descriptor is WEB-INF/validation.xml for web
>> modules and META-INF/validation.xml for all other types of modules.
>> 
>> 
>> 
>> 
>> --Nathan
>> _______________________________________________
>> beanvalidation-dev mailing list
>> beanvalidation-dev at lists.jboss.org <mailto:beanvalidation-dev at lists.jboss.org>
>> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev <https://lists.jboss.org/mailman/listinfo/beanvalidation-dev>
> 
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org <mailto:beanvalidation-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev <https://lists.jboss.org/mailman/listinfo/beanvalidation-dev>
> 
> 
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org <mailto:beanvalidation-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev <https://lists.jboss.org/mailman/listinfo/beanvalidation-dev>
> 
> 
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org <mailto:beanvalidation-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev <https://lists.jboss.org/mailman/listinfo/beanvalidation-dev>
> 
> 
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org <mailto:beanvalidation-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev <https://lists.jboss.org/mailman/listinfo/beanvalidation-dev>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/beanvalidation-dev/attachments/20170321/1da435e3/attachment-0001.html 


More information about the beanvalidation-dev mailing list