Skip to main content

[webtier] aligned url-pattern in web.xml

6 replies [Last post]
Anonymous

Hi Jan,

I have a servlet application with a few spaces in the url-pattern, which
deploys fine on Tomcat, not on GF.

AA

/aa.jsp

AA

/*

Deployment (in GFv3-ea-b42) failed with the following message.

message: Exception while deploying the app : java.lang.IllegalArgument
Exception: Invalid URL Pattern: [
/*
]
use-main-children-attribute: false

Changing the url-pattern to /* fixes the error.
The Servlet spec says:

URI paths specified in the deployment descriptor are assumed to be in
URL decoded form. The containers must inform the developer with a
descriptive error message when URL contains CR(#xD) or LF(#xA). The
containers must preserve all other characters including whitespace in URL.

Why is it so strict?
Can't it just catch the exception, do a trim() and try again?

Thanks,
Dies

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jan Luehe

Hi Dies,

On 04/21/09 04:59 PM, Dies Koper wrote:
> Hi Jan,
>
> I have a servlet application with a few spaces in the url-pattern, which
> deploys fine on Tomcat, not on GF.
>
>
>
>
> AA
>

>
> /aa.jsp
>

>

>
>
> AA
>

>
> /*
>

>

>

>
> Deployment (in GFv3-ea-b42) failed with the following message.
>
> message: Exception while deploying the app : java.lang.IllegalArgument
> Exception: Invalid URL Pattern: [
> /*
> ]
> use-main-children-attribute: false
>
> Changing the url-pattern to /* fixes the error.
> The Servlet spec says:
>
> URI paths specified in the deployment descriptor are assumed to be in
> URL decoded form. The containers must inform the developer with a
> descriptive error message when URL contains CR(#xD) or LF(#xA). The
> containers must preserve all other characters including whitespace in URL.
>
> Why is it so strict?
> Can't it just catch the exception, do a trim() and try again?
>

Yes, that might be a good idea!

I've seen this problem a few times as people were trying to migrate from
Tomcat to GlassFish.

Let me know if you'd be interested in working on a patch for this.

Thanks!

Jan

> Thanks,
> Dies
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Dies Koper

Hi Jan,

I can do that.

Just to make sure we agree what the patch will do:

1. First it will try to make a url without trimming (as the spec
explicitly says), as is done now.
2. If creation of the url failed, trim it, try again.
3. If the url could not be parsed after trimming, throw original error
(discard exception at 2).
4. If the url was successfully parsed, use it, but log a warning any way
(again, as the spec seems to explicitly mention it).

I can also implement 4 to only log a warning if the text included a
CR(#xD) or LF(#xA), to really follow the spec to the letter.

Regards,
Dies

Jan Luehe wrote:
> Hi Dies,
>
> On 04/21/09 04:59 PM, Dies Koper wrote:
>> Hi Jan,
>>
>> I have a servlet application with a few spaces in the url-pattern, which
>> deploys fine on Tomcat, not on GF.
>>
>>
>>
>>
>> AA
>>

>>
>> /aa.jsp
>>

>>

>>
>>
>> AA
>>

>>
>> /*
>>

>>

>>

>>
>> Deployment (in GFv3-ea-b42) failed with the following message.
>>
>> message: Exception while deploying the app : java.lang.IllegalArgument
>> Exception: Invalid URL Pattern: [
>> /*
>> ]
>> use-main-children-attribute: false
>>
>> Changing the url-pattern to /* fixes the
>> error.
>> The Servlet spec says:
>>
>> URI paths specified in the deployment descriptor are assumed to be in
>> URL decoded form. The containers must inform the developer with a
>> descriptive error message when URL contains CR(#xD) or LF(#xA). The
>> containers must preserve all other characters including whitespace in
>> URL.
>>
>> Why is it so strict?
>> Can't it just catch the exception, do a trim() and try again?
>>
>
> Yes, that might be a good idea!
>
> I've seen this problem a few times as people were trying to migrate from
> Tomcat to GlassFish.
>
> Let me know if you'd be interested in working on a patch for this.
>
> Thanks!
>
> Jan
>
>> Thanks,
>> Dies

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Jan Luehe

Hi Dies,

On 04/21/09 06:54 PM, Dies Koper wrote:
> Hi Jan,
>
> I can do that.
Great!
>
> Just to make sure we agree what the patch will do:
>
> 1. First it will try to make a url without trimming (as the spec
> explicitly says), as is done now.
> 2. If creation of the url failed, trim it, try again.
> 3. If the url could not be parsed after trimming, throw original error
> (discard exception at 2).
> 4. If the url was successfully parsed, use it, but log a warning any
> way (again, as the spec seems to explicitly mention it).
>
> I can also implement 4 to only log a warning if the text included a
> CR(#xD) or LF(#xA), to really follow the spec to the letter.

Sounds good!

Jan

>
> Regards,
> Dies
>
>
> Jan Luehe wrote:
>> Hi Dies,
>>
>> On 04/21/09 04:59 PM, Dies Koper wrote:
>>> Hi Jan,
>>>
>>> I have a servlet application with a few spaces in the url-pattern,
>>> which
>>> deploys fine on Tomcat, not on GF.
>>>
>>>
>>>
>>>
>>> AA
>>>

>>>
>>> /aa.jsp
>>>

>>>

>>>
>>>
>>> AA
>>>

>>>
>>> /*
>>>

>>>

>>>

>>>
>>> Deployment (in GFv3-ea-b42) failed with the following message.
>>>
>>> message: Exception while deploying the app : java.lang.IllegalArgument
>>> Exception: Invalid URL Pattern: [
>>> /*
>>> ]
>>> use-main-children-attribute: false
>>>
>>> Changing the url-pattern to /* fixes the
>>> error.
>>> The Servlet spec says:
>>>
>>> URI paths specified in the deployment descriptor are assumed to be in
>>> URL decoded form. The containers must inform the developer with a
>>> descriptive error message when URL contains CR(#xD) or LF(#xA). The
>>> containers must preserve all other characters including whitespace
>>> in URL.
>>>
>>> Why is it so strict?
>>> Can't it just catch the exception, do a trim() and try again?
>>>
>>
>> Yes, that might be a good idea!
>>
>> I've seen this problem a few times as people were trying to migrate from
>> Tomcat to GlassFish.
>>
>> Let me know if you'd be interested in working on a patch for this.
>>
>> Thanks!
>>
>> Jan
>>
>>> Thanks,
>>> Dies
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Dies Koper

Hi Jan, Hong,

Could you review my patch (attached to issue 7976)?
https://glassfish.dev.java.net/issues/show_bug.cgi?id=7976

If the url-pattern is aligned as follows, the resulting message will be:

/TPS

[#|2009-04-24T14:18:33.765+1000|WARNING|glassfish|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=19;_ThreadName=Thread-1;
/TPS
;|"DPL8023: URL Pattern contains CR(#xD) or LF(#xA): [
/TPS
]. Leading and trailing whitespace will be ignored."|#]

The only ugly bit about it is that the thread name(?) seems to include
the url pattern too. It would be nicer if it would use the trimmed name,
but I'm not sure where it gets set and how to chance it.

Any suggestions?

Regards,
Dies

Jan Luehe wrote:
> Hi Dies,
>
> On 04/21/09 06:54 PM, Dies Koper wrote:
>> Hi Jan,
>>
>> I can do that.
> Great!
>>
>> Just to make sure we agree what the patch will do:
>>
>> 1. First it will try to make a url without trimming (as the spec
>> explicitly says), as is done now.
>> 2. If creation of the url failed, trim it, try again.
>> 3. If the url could not be parsed after trimming, throw original error
>> (discard exception at 2).
>> 4. If the url was successfully parsed, use it, but log a warning any
>> way (again, as the spec seems to explicitly mention it).
>>
>> I can also implement 4 to only log a warning if the text included a
>> CR(#xD) or LF(#xA), to really follow the spec to the letter.
>
> Sounds good!
>
> Jan
>
>>
>> Regards,
>> Dies
>>
>>
>> Jan Luehe wrote:
>>> Hi Dies,
>>>
>>> On 04/21/09 04:59 PM, Dies Koper wrote:
>>>> Hi Jan,
>>>>
>>>> I have a servlet application with a few spaces in the url-pattern,
>>>> which
>>>> deploys fine on Tomcat, not on GF.
>>>>
>>>>
>>>>
>>>>
>>>> AA
>>>>

>>>>
>>>> /aa.jsp
>>>>

>>>>

>>>>
>>>>
>>>> AA
>>>>

>>>>
>>>> /*
>>>>

>>>>

>>>>

>>>>
>>>> Deployment (in GFv3-ea-b42) failed with the following message.
>>>>
>>>> message: Exception while deploying the app : java.lang.IllegalArgument
>>>> Exception: Invalid URL Pattern: [
>>>> /*
>>>> ]
>>>> use-main-children-attribute: false
>>>>
>>>> Changing the url-pattern to /* fixes the
>>>> error.
>>>> The Servlet spec says:
>>>>
>>>> URI paths specified in the deployment descriptor are assumed to be in
>>>> URL decoded form. The containers must inform the developer with a
>>>> descriptive error message when URL contains CR(#xD) or LF(#xA). The
>>>> containers must preserve all other characters including whitespace
>>>> in URL.
>>>>
>>>> Why is it so strict?
>>>> Can't it just catch the exception, do a trim() and try again?
>>>>
>>>
>>> Yes, that might be a good idea!
>>>
>>> I've seen this problem a few times as people were trying to migrate from
>>> Tomcat to GlassFish.
>>>
>>> Let me know if you'd be interested in working on a patch for this.
>>>
>>> Thanks!
>>>
>>> Jan
>>>
>>>> Thanks,
>>>> Dies

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Jan Luehe

Hi Dies,

On 04/26/09 11:45 PM, Dies Koper wrote:
> Hi Jan, Hong,
>
> Could you review my patch (attached to issue 7976)?
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=7976

Looks great!! Thanks for this patch!
>
> If the url-pattern is aligned as follows, the resulting message will be:
>
> /TPS
>

>
> [#|2009-04-24T14:18:33.765+1000|WARNING|glassfish|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=19;_ThreadName=Thread-1;
>
> /TPS
> ;|"DPL8023: URL Pattern contains CR(#xD) or LF(#xA): [
> /TPS
> ]. Leading and trailing whitespace will be ignored."|#]
>
> The only ugly bit about it is that the thread name(?) seems to include
> the url pattern too. It would be nicer if it would use the trimmed
> name, but I'm not sure where it gets set and how to chance it.
>
> Any suggestions?

Not sure. The thread name seems to be equal to "Thread-1" in your
example, and the remainder
of the line seems to be the warning message you wanted logged. I don't
see anything wrong with
that.

Jan

> Regards,
> Dies
>
>
> Jan Luehe wrote:
>> Hi Dies,
>>
>> On 04/21/09 06:54 PM, Dies Koper wrote:
>>> Hi Jan,
>>>
>>> I can do that.
>> Great!
>>>
>>> Just to make sure we agree what the patch will do:
>>>
>>> 1. First it will try to make a url without trimming (as the spec
>>> explicitly says), as is done now.
>>> 2. If creation of the url failed, trim it, try again.
>>> 3. If the url could not be parsed after trimming, throw original
>>> error (discard exception at 2).
>>> 4. If the url was successfully parsed, use it, but log a warning any
>>> way (again, as the spec seems to explicitly mention it).
>>>
>>> I can also implement 4 to only log a warning if the text included a
>>> CR(#xD) or LF(#xA), to really follow the spec to the letter.
>>
>> Sounds good!
>>
>> Jan
>>
>>>
>>> Regards,
>>> Dies
>>>
>>>
>>> Jan Luehe wrote:
>>>> Hi Dies,
>>>>
>>>> On 04/21/09 04:59 PM, Dies Koper wrote:
>>>>> Hi Jan,
>>>>>
>>>>> I have a servlet application with a few spaces in the url-pattern,
>>>>> which
>>>>> deploys fine on Tomcat, not on GF.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> AA
>>>>>

>>>>>
>>>>> /aa.jsp
>>>>>

>>>>>

>>>>>
>>>>>
>>>>> AA
>>>>>

>>>>>
>>>>> /*
>>>>>

>>>>>

>>>>>

>>>>>
>>>>> Deployment (in GFv3-ea-b42) failed with the following message.
>>>>>
>>>>> message: Exception while deploying the app :
>>>>> java.lang.IllegalArgument
>>>>> Exception: Invalid URL Pattern: [
>>>>> /*
>>>>> ]
>>>>> use-main-children-attribute: false
>>>>>
>>>>> Changing the url-pattern to /* fixes
>>>>> the error.
>>>>> The Servlet spec says:
>>>>>
>>>>> URI paths specified in the deployment descriptor are assumed to be in
>>>>> URL decoded form. The containers must inform the developer with a
>>>>> descriptive error message when URL contains CR(#xD) or LF(#xA). The
>>>>> containers must preserve all other characters including whitespace
>>>>> in URL.
>>>>>
>>>>> Why is it so strict?
>>>>> Can't it just catch the exception, do a trim() and try again?
>>>>>
>>>>
>>>> Yes, that might be a good idea!
>>>>
>>>> I've seen this problem a few times as people were trying to migrate
>>>> from
>>>> Tomcat to GlassFish.
>>>>
>>>> Let me know if you'd be interested in working on a patch for this.
>>>>
>>>> Thanks!
>>>>
>>>> Jan
>>>>
>>>>> Thanks,
>>>>> Dies
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Dies Koper

Hi Jan, Hong,

>> Could you review my patch (attached to issue 7976)?
>> https://glassfish.dev.java.net/issues/show_bug.cgi?id=7976
>
> Looks great!! Thanks for this patch!

I'm doing something else at the moment, but I'll commit it this or early
next week then.

>> If the url-pattern is aligned as follows, the resulting message will be:
>>
>> /TPS
>>

>>
>> [#|2009-04-24T14:18:33.765+1000|WARNING|glassfish|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=19;_ThreadName=Thread-1;
>>
>> /TPS
>> ;|"DPL8023: URL Pattern contains CR(#xD) or LF(#xA): [
>> /TPS
>> ]. Leading and trailing whitespace will be ignored."|#]
>>
>> The only ugly bit about it is that the thread name(?) seems to include
>> the url pattern too. It would be nicer if it would use the trimmed
>> name, but I'm not sure where it gets set and how to chance it.
>>
>> Any suggestions?
>
> Not sure. The thread name seems to be equal to "Thread-1" in your
> example, and the remainder
> of the line seems to be the warning message you wanted logged. I don't
> see anything wrong with
> that.

I thought '|' is used as separator between thread name and message.
As you can see from the message file, my message is defined as:

enterprise.deployment.backend.urlcontainscrlf="DPL8023: URL Pattern
contains CR(#xD) or LF(#xA): [{0}]. Leading and trailing whitespace will
be ignored."

I'm including the offending url pattern once but in the example above it
is logged twice.
If url-patterns are logged in the thread name for each message related
to the filter or servlet using this pattern, as it looks ugly, I'd like
to make sure that value is trimmed too.

Regards,
Dies

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net