Re: How Tomcat validates web.xml

2005-04-07 Thread N G
On Apr 6, 2005 10:07 PM, Jeanfrancois Arcand
<[EMAIL PROTECTED]> wrote:
> 
> 
> N G wrote:
> > On Apr 6, 2005 10:31 AM, Jeanfrancois Arcand <[EMAIL PROTECTED]> wrote:
> > SO, are you saying that even though Tomcat will accept whatever you
> > put for the path to the Schema (since it uses its own copy), the app
> > will not necessarily be portable to other servers since they might
> > choose to actually pay attention to the schema location specified by
> > web.xml?
> >
> > So, to guarantee that the app is 100% portable, you must specify:
> >
> > http://java.sun.com/xml/ns/j2ee";
> >   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >   xsi:schemaLocation=
> >   "http://java.sun.com/xml/ns/j2ee
> > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
> >   version="2.4">
> >
> >
> > Am I correct?
> 
> We use SAX when parsing/validating the web.xml, and at the time we
> resolve the XML entity, we use the system ID to redirect the stream to
> our internal version. So if you don't have everything required in your
>  element, then it will fail because the parser (unfortunalty
> we use buggy Xerces ;-)) will not be able to create properly its schema
> table, unless you are connected to the internet and we are able to
> resolve the uri.
> 
> So I don't see why your app deployed/validated in Tomcat will not be
> portable. Do you have a test case?

Yes, I do. Try this header in your web.xml in Tomcat 5.5.7 and the app
will deploy with no problems:
http://java.sun.com/xml/ns/j2ee";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation=
   "http://java.sun.com/xml/ns/j2ee whatever"
   version="2.4">

Now, while I don't really have another 2.4 compliant server to try
this on right now, EVEN ACCORDING TO YOU (as you correctly pointed out
in the spec.), another server HAS THE RIGHT to validate this file
however it wants. So, it might choose to validate it by actually
paying attention to the schema location specified. Thus, the above
declaration will fail and is therefore NOT portable!

Am I wrong?

Thanks,
NG.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How Tomcat validates web.xml

2005-04-06 Thread N G
On Apr 6, 2005 10:31 AM, Jeanfrancois Arcand <[EMAIL PROTECTED]> wrote:
> Tomcat uses it's own local version. This way you can use Tomcat without
> being connected to the internet, or pay the price of connection over
> http everytime a war is deployed.
> 
> > And what's WAY more important: what does the servlet spec say about
> > how a server should validate web.xml?
> 
> See the Servlet Spec.
> >
> > SRV.13.2 Rules for Processing the Deployment Descriptor
> > This section lists some general rules that Web containers and developers 
> > must note
> > concerning the processing of the deployment descriptor for a Web 
> > application.
> >  · Web containers must remove all leading and trailing whitespace, which is 
> > de-
> >fined as "S(white space)" in XML 1.0 (http://www.w3.org/TR/2000/WD-xml-
> >2e-2814), for the element content of the text nodes of a deployment 
> > de-
> >scriptor.
> >  · The deployment descriptor must be valid against the schema. Web 
> > containers
> >and tools that manipulate Web applications have a wide range of options 
> > for
> >checking the validity of a WAR. This includes checking the validity of 
> > the de-
> >ployment descriptor document held within. The containers and tools that 
> > are
> >part of J2EE technology-compliant implementation are required to validate
> >deployment descriptor against the XML schema for structural correctness.
> >The validation is recommended, but not required for the web containers 
> > and
> >tools that are not part of J2EE technology-compliant implementation.

Yes, I saw this. However, what gives a PORTABLE application the right
to specify a relative URL for the location of the Schema and not
provide that schema there? I don't see anything in this paragraph that
says this is allowed.

SO, are you saying that even though Tomcat will accept whatever you
put for the path to the Schema (since it uses its own copy), the app
will not necessarily be portable to other servers since they might
choose to actually pay attention to the schema location specified by
web.xml?

So, to guarantee that the app is 100% portable, you must specify:

http://java.sun.com/xml/ns/j2ee";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation=
  "http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
  version="2.4">


Am I correct?

Thanks,
NG.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How Tomcat validates web.xml

2005-04-06 Thread N G
Hi,

I found some strange behavior while using Tomcat 5.5.7. In my web.xml
Schema declaration, I have this:

http://java.sun.com/xml/ns/j2ee";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation=
   "http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
 version="2.4">

(I enabled xmlValidation="true" for Host element in server.xml)

I found it odd that under schemaLocation, a relative URL is given to
the XSD file. Yet, there is no "web-app_2_4.xsd" file in WEB-INF
directory. How does it validate web.xml then?

So, I substituted "web-app_2_4.xsd" with the word "whatever". To my
surprise it worked again without any problems.

What is going on? How does Tomcat validate web.xml of an application?
And what's WAY more important: what does the servlet spec say about
how a server should validate web.xml? I didn't see anything there at
all about this, so I assumed that regular XML rules apply.

Could someone straighten me out on this issue?

Thanks,
NG.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]