roller-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Mazza <glen.ma...@gmail.com>
Subject Re: Error when accessing webapp without trailing slash
Date Tue, 18 Nov 2014 01:03:35 GMT
Hi Sean, thanks for bringing this to our attention and for trying 
Roller.  I had trouble replicating this issue, all three browsers I 
tried, Chrome, Firefox and Konqueror, using Tomcat 8.0.x, appended a 
trailing slash to the URL even if I didn't provide it, allowing the blog 
to be seen.  I would have thought a Tomcat-initiated redirect from "xxx" 
to "xxx/" was occurring, but I next tried the cURL utility 
(http://curl.haxx.se/), and it indeed behaved differently between 
http://web-gmazza.rhcloud.com/blog (showing nothing) and 
http://web-gmazza.rhcloud.com/blog/ (showing my blog).  However, your 
proposed fix didn't seem to solve that issue, cURL still couldn't report 
back the blog with the former.

That's a heavily used section of the code, activated anytime webpages 
and their Roller-stored CSS/JS resources are retrieved, and seems to 
work fine for other Roller bloggers. I'm reluctant to change it, 
possibly introducing other problems in the process, unless I can 
reproduce this bug in some browser and see how the code change fixes 
it.  If this is a code bug it should be reproducible with Tomcat, I 
shouldn't have to download Resin to replicate it.

Regards,
Glen

On 11/16/2014 08:32 PM, Sean Pritchard wrote:
> I confirmed that the change I suggested does fix the problem.  Simply wrap
> line 112 of WeblogRequestMapper with the following if().
>
> if(servlet.startsWith("/")) {
>      servlet = servlet.substring(1);  //old line 112
> }
>
> I hope this can be included in a future release.  I don't want to have to
> apply the change each time I upgrade.  :)
>
> Regards,
> Sean
>
>
> On Sun, Nov 16, 2014 at 5:45 PM, Sean Pritchard <spritchard@militaryhire.com
>> wrote:
>> As a follow up, I edited the error.jsp to dump the stack trace.  Here it
>> it (partial)
>>
>> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>>      at java.lang.String.substring(String.java:1875)
>>      at
>> org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper.handleRequest(WeblogRequestMapper.java:112)
>>      at
>> org.apache.roller.weblogger.ui.rendering.filters.RequestMappingFilter.doFilter(RequestMappingFilter.java:120)
>>      at
>> com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:89)
>>      at
>> org.apache.roller.weblogger.ui.core.filters.InitFilter.doFilter(InitFilter.java:73)
>>
>> The error seems to be happening on the last line of this snippet from
>> WeblogRequestMapper:
>>
>>          // figure out potential weblog handle
>>          String servlet = request.getRequestURI();
>>          String pathInfo = null;
>>
>>          if(servlet != null && servlet.trim().length() > 1) {
>>
>>              if(request.getContextPath() != null) {
>>                  servlet =
>> servlet.substring(request.getContextPath().length());
>>              }
>>
>>              // strip off the leading slash
>>              servlet = servlet.substring(1); //line 112
>>
>> Seems like the assumption is that at least a "/" remains in servlet at
>> this point.  Without launching an argument about spec compliance, it seems
>> this could be easily fixed by changing the last line to:
>>
>> if(servlet.startsWith("/")) {
>>      servlet = servlet.substring(1);
>> }
>>
>> I will probably make that change locally to work around this issue, but it
>> would be helpful if the change were included in future releases.
>>
>> Regards,
>> Sean
>>
>>
>>
>>
>>
>>
>>
>> On Sun, Nov 16, 2014 at 4:19 PM, Sean Pritchard <
>> spritchard@militaryhire.com> wrote:
>>
>>> Hello,
>>>
>>> I've recently installed and started using Roller 5.1.1.  I deployed it to
>>> the Resin 4 app server.
>>>
>>> I renamed roller.war to blog.war to deploy to the path /blog/.  But I'm
>>> running into a problem where if I request the blog at
>>> http://hostname/blog/ it works fine.  But if I remove the trailing slash
>>> http://hostname/blog, I get the following error:
>>>
>>> Unexpected Exception Status Code 500  Message String index out of range:
>>> -1  Type
>>>   Exception Roller has encountered and logged an unexpected exception.
>>> In checking the roller.log, I see no evidence of an exception.  I tried
>>> changing the roller logging levels to DEBUG
>>>
>>> log4j.logger.org.apache.roller=DEBUG
>>> log4j.logger.net.java.roller=DEBUG
>>>
>>> But still no stack trace.  From the log, I'm guessing the problem is
>>> happening in the WeblogRequestMapper.  My two clues are at 16:03:13,361
>>> where the session is released immediately after evaluating the path /blog.
>>> Or perhaps at 16:03:14,138 where the request is not mapped.
>>>
>>> DEBUG 2014-11-16 16:03:13,333 CharEncodingFilter:doFilter - Processing
>>> CharEncodingFilter
>>> DEBUG 2014-11-16 16:03:13,334 CharEncodingFilter:doFilter - Set request
>>> character encoding to UTF-8
>>> DEBUG 2014-11-16 16:03:13,358 BootstrapFilter:doFilter - Entered /blog
>>> DEBUG 2014-11-16 16:03:13,359 WebloggerConfig:getProperty - Fetching
>>> property [installation.type=manual]
>>> DEBUG 2014-11-16 16:03:13,359 PersistenceSessionFilter:doFilter - Entered
>>> /blog
>>> DEBUG 2014-11-16 16:03:13,360 InitFilter:doFilter - relPath = /blog
>>> DEBUG 2014-11-16 16:03:13,360 InitFilter:doFilter - absPath =
>>> http://localhost:8080/blog
>>> DEBUG 2014-11-16 16:03:13,360 RequestMappingFilter:doFilter - entering
>>> DEBUG 2014-11-16 16:03:13,361 RequestMappingFilter:doFilter - trying
>>> mapper org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
>>> DEBUG 2014-11-16 16:03:13,361 WeblogRequestMapper:handleRequest -
>>> evaluating [/blog]
>>> DEBUG 2014-11-16 16:03:13,361 PersistenceSessionFilter:doFilter -
>>> Releasing Roller Session
>>> DEBUG 2014-11-16 16:03:14,127 CharEncodingFilter:doFilter - Processing
>>> CharEncodingFilter
>>> DEBUG 2014-11-16 16:03:14,128 CharEncodingFilter:doFilter - Set request
>>> character encoding to UTF-8
>>> DEBUG 2014-11-16 16:03:14,129 BootstrapFilter:doFilter - Entered
>>> /blog/roller-ui/styles/roller.css
>>> DEBUG 2014-11-16 16:03:14,129 WebloggerConfig:getProperty - Fetching
>>> property [installation.type=manual]
>>> DEBUG 2014-11-16 16:03:14,130 PersistenceSessionFilter:doFilter - Entered
>>> /blog/roller-ui/styles/roller.css
>>> DEBUG 2014-11-16 16:03:14,132 WebloggerConfig:getProperty - Fetching
>>> property [cache.salt.enabled=true]
>>> DEBUG 2014-11-16 16:03:14,132 WebloggerConfig:getProperty - Fetching
>>> property [cache.salt.size=5000]
>>> DEBUG 2014-11-16 16:03:14,132 WebloggerConfig:getProperty - Fetching
>>> property [cache.salt.timeout=3600]
>>> INFO  2014-11-16 16:03:14,132 SaltCache:<init> - {id=cache.salt,
>>> enabled=true, timeout=3600, size=5000}
>>> DEBUG 2014-11-16 16:03:14,133 CacheManager:constructCache - Constructing
>>> new cache with props {id=cache.salt, enabled=true, timeout=3600, size=5000}
>>> DEBUG 2014-11-16 16:03:14,133 ExpiringLRUCacheFactoryImpl:constructCache
>>> - new cache constructed. size=5000, timeout=3600
>>> DEBUG 2014-11-16 16:03:14,136 SaltCache:put - PUT kY1lSl8jyUyRCMfhyj8Z
>>> DEBUG 2014-11-16 16:03:14,136 RequestMappingFilter:doFilter - entering
>>> DEBUG 2014-11-16 16:03:14,137 RequestMappingFilter:doFilter - trying
>>> mapper org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper
>>> DEBUG 2014-11-16 16:03:14,137 WeblogRequestMapper:handleRequest -
>>> evaluating [/blog/roller-ui/styles/roller.css]
>>> DEBUG 2014-11-16 16:03:14,137 WeblogRequestMapper:handleRequest -
>>> potential weblog handle = roller-ui
>>> DEBUG 2014-11-16 16:03:14,137 WeblogRequestMapper:handleRequest - SKIPPED
>>> roller-ui
>>> DEBUG 2014-11-16 16:03:14,138 RequestMappingFilter:doFilter - request not
>>> mapped
>>> DEBUG 2014-11-16 16:03:14,172 RequestMappingFilter:doFilter - exiting
>>> DEBUG 2014-11-16 16:03:14,173 PersistenceSessionFilter:doFilter -
>>> Releasing Roller Session
>>> DEBUG 2014-11-16 16:03:14,173 PersistenceSessionFilter:doFilter - Exiting
>>> /blog/roller-ui/styles/roller.css
>>> DEBUG 2014-11-16 16:03:14,173 BootstrapFilter:doFilter - Exiting
>>> /blog/roller-ui/styles/roller.css
>>>
>>> Have any of you run into this problem and know how to fix it?
>>>
>>> Thanks in advance,
>>> Sean
>>>
>>


Mime
View raw message