On 29/02/12 11:51, Carlo de Wolf wrote:
On 02/24/2012 04:57 PM, Jason T. Greene wrote:
> On 2/24/12 8:36 AM, Paul Robinson wrote:
>> A common problem I see again and again is when people miss-spell the
>> filenames of XML artefacts that live in the META-INF and WEB-INF
>> directories of a JEE archive. I also see people (myself included)
>> putting these artefacts in the wrong location, For example, putting the
>> beans.xml file in the META-INF of a .war when it belongs in the WEB-INF.
>> This can cause a big headache as it looks like you have created the
>> right artifact, but it is not taking effect. It would be great if we
>> could detect this type of thing and warn the developer at deploy time.
>> There seems to be a move towards using marker files (beans.xml,
>> faces-config.xml) to enable technologies, so this issue could become
>> more prevalent.
>>
>> One solution, I was thinking about, is to check the schema type of all
>> the XML files in the META-INF and WEB-INF directories. For each schema
>> that we recognize (
http://java.sun.com/xml/ns/persistence for example),
>> we check that it's file name is correct and it is in a location where it
>> will be processed.
>>
>> Does this sound like a sensible thing for us to do?
> I think the idea is good, but looking at the content of all xml files
> would slow down deployment time, especially for large complex nested
> deployments. So if we did this as part of deployment it would be more
> efficient to do it based on file name matching. Common misspellings
> could be checked for using a static map. So I would still prefer
> extensive checking like this to be an optional deployment tool/maven
> task. If however someone comes up with a patch which is able to
> demonstrate no significant delay, we would certain reconsider.
>
How about we simple look through META-INF/* and INFO anything that we
can't process?
Keeping a simple configuration in domain with white/black list expressions.
Sounds
like it hits my requirements:
1) User puts a file in the wrong location. As long as they put it in a
"sensible" location, we flag it as not processed.
2) User puts a file in the right location but with a typo in the name.
We flag it as not processed.
It wouldn't be quite as usable as the more expensive approach. As the
warning would look like this:
"Found unexpected 'beans.xml' in /META-INF. The file was not processed
as it was in the wrong location and/or was not named correctly"
With more information we could say:
"Found unexpected 'beans.xml' in /META-INF. This file should be located
in /WEB-INF."
It seems like the two simplest approaches are:
1) This approach, which has reduced usability due to the available
information for warning messgaes
2) Max's approach of delaying checking till after deployment. This
approach can display better warning messages, but potentially adds noise
after the "deployment complete" log line.
Paul.
--
Paul Robinson
Web service transactions lead
paul.robinson(a)redhat.com
JBoss, a Division of Red Hat
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham (USA), Brendan Lane (Ireland), Matt Parson
(USA), Charlie Peters (USA)