persistence@glassfish.java.net

Re: Validation of XML DD for persistence api

From: Bill Shannon <bill.shannon_at_sun.com>
Date: Fri, 10 Mar 2006 16:13:02 -0800

Sanjeeb Kumar Sahoo wrote:
> Hi Mike,
>
> I don't recollect to have seen any requirement about validation of
> deployment descriptors in Java Persistence API spec. So, in Java SE, is
> a provider not *required* to validate persistence.xml and orm.xml? We
> should add this restriction in the spec.
>
> In Java EE we have a slightly different problem. As per the Java EE
> platform rules, XML deployment descriptors must be validated against
> corresponding dtd/schema during deployment. Question is who is
> responsible for this validation? My assumption is that container *must*
> validate persistence.xml and persistence provider *must* validate
> mapping xml(orm.xml). Is this a correct assumption?
>
> During a discussion with Marina, this issue came up. We felt it is
> necessary to get a clarification on this regard.
> TopLink Essential does not validate any of them. See bugs:
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=384 and
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=385
>
> Thanks,
> Sahoo
>

The Java EE platform spec talks about deployment descriptors. These
aren't clearly deployment descriptors so it's ambiguous at best as to
whether they're covered by the platform spec requirements.

In general, we've required that deployment descriptors are validated
because it catches errors earlier and improves portability of
applications. Unfortunately, some products (e.g., Tomcat) haven't
validated descriptors, and have bee more "forgiving" of errors. This
has definitely had an impact on portability and has made it harder to
impose the validation requirement in all cases. We've had to compromise
and not require it in the servlet spec and instead add that requirement
in the Java EE spec. That's not something I'd like to see happen with
Java Persistence.

Best would be that the Java Persistence spec requires that these xml
files are validated before use, and defines what fails how if the
validation fails, and that these requirements apply in all cases
(e.g., Java SE and Java EE).