users@jersey.java.net

Re: exception when accessing servlet root URL

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 22 Feb 2008 18:13:21 +0100

Hi Gabor,

Gabor Szokoli wrote:
> Hi there,
>
> I've just started using jersey, but failed to find a FAQ page.

There is one here that any one may edit, but i have not had time to
place content.


> Was
> there one, I'm sure it'd begin with this exception I get with both 0.4
> and 0.5 versions of jersey when accessing the root servlet URL from a
> browser.

Definitely a bug! Thanks for reporting it. I would hope that would not
go in a FAQ :-)


> I reproduced the "hello world" ws from "Sud's blog", packaged into a
> war, deployed to Glassfish V2 on Ubuntu 7.10 x86.
> The proper URL works fine, malformed URLs provide 404 as they should,
> except for the "null" URL, the context-root of the servlet.
>

I reproduced it with the hello world web app example.

Grrr.. sometimes Servlet is so vague...

The following is the output from the HttpServletRequest for two URLs
(returning a 404 and 500 respectively):

   http://localhost:8084/HelloWorldWebApp/

      getPathInfo(): /
   getContextPath(): /HelloWorldWebApp
   getServletPath():
   getRequestURI(): /HelloWorldWebApp/


   http://localhost:8084/HelloWorldWebApp/

      getPathInfo(): /
   getContextPath(): /HelloWorldWebApp
   getServletPath():
    getRequestURI(): /HelloWorldWebApp


Notice that the path info is the same for both... perhaps this is a bug
in GF and Tomcat ?

I have a temporary fix, but i am not happy with it, need to think about
it a bit more.

Paul.

[1] http://wikis.sun.com/display/Jersey/FAQ


> [#|2008-02-22T16:34:35.393+0100|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=a1c6e2f9-3b8b-49f9-92e6-949d14524f78;|StandardWrapperValve[Jersey
> Web Application]: PWC1406: Servlet.service() for servlet Jersey Web
> Application threw exception
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.substring(String.java:1938)
> at java.lang.String.substring(String.java:1905)
> at com.sun.ws.rest.spi.container.AbstractContainerRequest.getEncodedPath(AbstractContainerRequest.java:233)
> at com.sun.ws.rest.spi.container.AbstractContainerRequest.getPath(AbstractContainerRequest.java:226)
> at com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:238)
> at com.sun.ws.rest.spi.container.servlet.ServletContainer.service(ServletContainer.java:123)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
> at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
> at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
> at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
> at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
> at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
> |#]
>
>
> Thanks in advance!
>
> Gabor Szokoli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109