users@jersey.java.net

Re: [Jersey] SpringServlet and Viewables (JSPTemplateProcessor)

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Nov 2009 17:29:25 +0100

On Nov 10, 2009, at 5:22 PM, Cemo Koc wrote:

>
> Hi Paul,
>
> Now I changed my web.xml as you made. :)
>
> Now it is working fine. Thank you so much.
>
> I tested in 1.1.2-ea too... It is also working.
>

Great! i dunno why GF embedded is not working for me :-(

Paul.

> Thank you so much.
>
>
>
> Paul Sandoz wrote:
>>
>> Hi,
>>
>> Try:
>>
>> http://localhost:8080/bookstore/
>>
>> I am not quite sure why including Spring results in a
>> StringIndexOutOfBoundsException for the URL:
>>
>> http://localhost:8080/bookstore
>>
>> There was a bug i fixed a while ago for such edge cases. And from
>> your
>> stack trace you present there are no Spring-related classes in the
>> call stack.
>>
>> Paul.
>>
>> On Nov 10, 2009, at 3:02 PM, Cemo Koc wrote:
>>
>>>
>>> Hi Paul,
>>>
>>>
>>> I have tried at latest stable and ea version. (1.0.3.1 and 1.1.2-ea)
>>>
>>> Both of the application did not work when I tried embedded
>>> glassfish.
>>>
>>> When I send a request to
>>>
>>> http://localhost:8080/bookstore
>>>
>>> The expection at the below is thrown:
>>>
>>> java.lang.StringIndexOutOfBoundsException: String index out of
>>> range: -1
>>> at java.lang.String.substring(String.java:1937)
>>> at java.lang.String.substring(String.java:1904)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi
>>> .container.ContainerRequest.getEncodedPath(ContainerRequest.java:
>>> 315)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi.container.ContainerRequest.getPath(ContainerRequest.java:
>>> 308)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .server
>>> .impl
>>> .application
>>> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:676)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .server
>>> .impl
>>> .application
>>> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:647)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .server
>>> .impl
>>> .application
>>> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:638)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi.container.servlet.WebComponent.service(WebComponent.java:
>>> 309)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi
>>> .container.servlet.ServletContainer.service(ServletContainer.java:
>>> 425)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi
>>> .container.servlet.ServletContainer.doFilter(ServletContainer.java:
>>> 737)
>>> at
>>> com
>>> .sun
>>> .jersey
>>> .spi
>>> .container.servlet.ServletContainer.doFilter(ServletContainer.java:
>>> 689)
>>> at
>>> org
>>> .apache
>>> .catalina
>>> .core
>>> .ApplicationFilterChain
>>> .internalDoFilter(ApplicationFilterChain.java:
>>> 246)
>>> at
>>> org
>>> .apache
>>> .catalina
>>> .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
>>> 214)
>>> at
>>> org
>>> .apache
>>> .catalina
>>> .core.StandardWrapperValve.invoke(StandardWrapperValve.java:
>>> 313)
>>> at
>>> org
>>> .apache
>>> .catalina
>>> .core.StandardContextValve.invokeInternal(StandardContextValve.java:
>>> 287)
>>> at
>>> org
>>> .apache
>>> .catalina
>>> .core.StandardContextValve.invoke(StandardContextValve.java:
>>> 218)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
>>> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:
>>> 94)
>>> at
>>> com
>>> .sun
>>> .enterprise
>>> .web
>>> .PESessionLockingStandardPipeline
>>> .invoke(PESessionLockingStandardPipeline.java:98)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
>>> at
>>> org
>>> .apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
>>> 587)
>>> at
>>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
>>> 1093)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
>>> 166)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
>>> at
>>> org
>>> .apache
>>> .catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
>>> at
>>> org
>>> .apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
>>> 587)
>>> at
>>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
>>> 1093)
>>> at
>>> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:
>>> 291)
>>> at
>>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter
>>> (DefaultProcessorTask.java:666)
>>> at
>>> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess
>>> (DefaultProcessorTask.java:597)
>>> at
>>> com
>>> .sun
>>> .enterprise
>>> .web
>>> .connector
>>> .grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:872)
>>> at
>>> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask
>>> (DefaultReadTask.java:341)
>>> at
>>> com
>>> .sun
>>> .enterprise
>>> .web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:
>>> 263)
>>> at
>>> com
>>> .sun
>>> .enterprise
>>> .web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:
>>> 214)
>>> at
>>> com.sun.enterprise.web.portunif.PortUnificationPipeline
>>> $PUTask.doTask(PortUnificationPipeline.java:382)
>>> at
>>> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:
>>> 264)
>>> at
>>> com
>>> .sun
>>> .enterprise
>>> .web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:
>>> 106)
>>>
>>> By the way,
>>>
>>> If I comment out
>>>
>>> <servlet-mapping>
>>> <servlet-name>Spring Service Web Application</servlet-name>
>>> <url-pattern>/*</url-pattern>
>>> </servlet-mapping>
>>>
>>> (<servlet-
>>> class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</
>>> servlet-class>)
>>>
>>> Everything is working fine.
>>>
>>> Now I will try your codes....
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Paul Sandoz wrote:
>>>>
>>>> Hi,
>>>>
>>>> What version of Jersey are you using?
>>>>
>>>> Any errors in the server log?
>>>>
>>>> Paul.
>>>>
>>>> On Nov 10, 2009, at 11:18 AM, Cemo Koc wrote:
>>>>
>>>>>
>>>>> Hi all and Paul :),
>>>>>
>>>>> I have some problem with working spring about returning Views. I
>>>>> am
>>>>> not sure
>>>>> weather I did necessary things correctly or not. But to reproduce
>>>>> such a
>>>>> problem, I made modificiations on bookstore example and also added
>>>>> modified
>>>>> project as a attachment.
>>>>>
>>>>>
>>>>>
>>>>> 1.
>>>>>
>>>>> I have added to bookstore sample
>>>>>
>>>>> <dependency>
>>>>> <groupId>com.sun.jersey.contribs</groupId>
>>>>> <artifactId>jersey-spring</artifactId>
>>>>> <version>${project.version}</version>
>>>>> </dependency>
>>>>>
>>>>> 2.
>>>>>
>>>>> Empty Application.xml is added
>>>>>
>>>>>
>>>>> 3.
>>>>>
>>>>> I have added necessary things to web.xml (with resource packages
>>>>> param)
>>>>>
>>>>> <context-param>
>>>>> <param-name>contextConfigLocation</param-name>
>>>>> <param-value>classpath:applicationContext.xml</param-value>
>>>>> </context-param>
>>>>>
>>>>> <listener>
>>>>>
>>>>> <listener-
>>>>> class>org.springframework.web.context.ContextLoaderListener</
>>>>> listener-class>
>>>>> </listener>
>>>>> <listener>
>>>>>
>>>>> <listener-class>org.springframework.web.context.request.RequestContextListener
>>>>> </listener-class>
>>>>> </listener>
>>>>> <servlet>
>>>>> <servlet-name>Spring Service Web Application</servlet-name>
>>>>>
>>>>> <servlet-
>>>>> class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</
>>>>> servlet-class>
>>>>>
>>>>> <init-param>
>>>>> <param-name>com.sun.jersey.config.property.packages</
>>>>> param-name>
>>>>>
>>>>> <param-value>com.sun.jersey.samples.bookstore.resources</param-
>>>>> value>
>>>>> </init-param>
>>>>> <!--<load-on-startup>3</load-on-startup>-->
>>>>>
>>>>> </servlet>
>>>>> <servlet-mapping>
>>>>> <servlet-name>Spring Service Web Application</servlet-name>
>>>>> <url-pattern>/*</url-pattern>
>>>>> </servlet-mapping>
>>>>>
>>>>>
>>>>> 4.
>>>>> mvn glassfish:run
>>>>>
>>>>>
>>>>> 5. http://localhost:8080/bookstore is not working properly.
>>>>>
>>>>>
>>>>> What did I made wrong? I am not sure but I suspected something in
>>>>> JSPTemplateProcessor. But I am not sure...
>>>>>
>>>>> Thanks
>>>>>
>>>>>
>>>>>
>>>>> http://n2.nabble.com/file/n3978757/bookstore.zip bookstore.zip
>>>>> --
>>>>> View this message in context:
>>>>> http://n2.nabble.com/SpringServlet-and-Viewables-JSPTemplateProcessor-tp3978757p3978757.html
>>>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/SpringServlet-and-Viewables-JSPTemplateProcessor-tp3978757p3979824.html
>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
> --
> View this message in context: http://n2.nabble.com/SpringServlet-and-Viewables-JSPTemplateProcessor-tp3978757p3980827.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>