users@jersey.java.net

Re: [Jersey] Re: Problems when deploying in Websphere 7.0.0.3

From: Dinesh Narayanan <ndchandar_at_gmail.com>
Date: Tue, 13 Oct 2009 03:18:04 -0700

Paul,
 Pls find my reply inline for your question on out.flush().

Thanks
Dinesh


On Tue, Oct 13, 2009 at 1:37 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> Hi Dinesh,
> On Oct 10, 2009, at 12:23 PM, Dinesh Narayanan wrote:
>
> I also noticed that since I was using only explicit views in my code for
> now, when I commented out ImplicitViews properties in web.xml
> (com.sun.jersey.config.feature.Redirect and
> com.sun.jersey.config.feature.ImplicitViewables), I got the following
> exception
>
>
> That is odd, because in your case those properties should not make any
> difference. Plus in either case implicit or explicit the same code is
> invoked for forwarding to a JSP.
>
> The JSPTemplateProcessor.writeTo method does the following:
>
> public void writeTo(String resolvedPath, Object model, OutputStream
> out) throws IOException {
> // Commit the status and headers to the HttpServletResponse
> out.flush();
>
> RequestDispatcher d =
> servletContext.getRequestDispatcher(resolvedPath);
> if (d == null) {
> throw new ContainerException("No request dispatcher for: " +
> resolvedPath);
> }
>
> d = new RequestDispatcherWrapper(d, basePath, hc, model);
>
> try {
> d.forward(requestInvoker.get(), responseInvoker.get());
> } catch (Exception e) {
> throw new ContainerException(e);
> }
> }
>
> I am wondering if the "out.flush()" is causing WebSphere to think the
> response has been committed?
>

[Dinesh] I was getting the same error even if I was commented out.flush().
The error occurs when the following statement is executed in
JSPTemplateProcessor.writeTo(...) method
            d.forward(requestInvoker.get(), responseInvoker.get());



>
> You could verify this by copying the JSPTemplateProcessor to your own
> class, annotating it with the JAX-RS annotation @Provider and registering
> that class just like you would register a root resource class (annotated
> with @Path).
>
> Paul.
>
> [10/10/09 2:47:54:913 PDT] 00000030 srt W
> com.ibm.ws.webcontainer.srt.SRTServletResponse setStatus WARNING: Cannot set
> status. Response already committed.
> [10/10/09 2:47:54:960 PDT] 00000030 srt W
> com.ibm.ws.webcontainer.srt.SRTServletResponse addHeader WARNING: Cannot set
> header. Response already committed.
> [10/10/09 2:47:54:960 PDT] 00000030 webapp E
> com.ibm.ws.webcontainer.webapp.WebApp logError SRVE0293E: [Servlet
> Error]-[Cannot forward. Response already committed.]:
> com.sun.jersey.api.container.ContainerException:
> java.lang.IllegalStateException: Cannot forward. Response already committed.
> at
> com.sun.jersey.server.impl.container.servlet.JSPTemplateProcessor.writeTo(JSPTemplateProcessor.java:123)
> at
> com.sun.jersey.spi.template.ResolvedViewable.writeTo(ResolvedViewable.java:102)
> at
> com.sun.jersey.server.impl.template.ViewableMessageBodyWriter.writeTo(ViewableMessageBodyWriter.java:81)
> at
> com.sun.jersey.server.impl.template.ViewableMessageBodyWriter.writeTo(ViewableMessageBodyWriter.java:58)
> at
> com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:266)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:763)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:689)
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:680)
> at
> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:324)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:425)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:751)
> at
> com.sun.jersey.spi.container.servlet.ServletContainer.doFilter(ServletContainer.java:703)
> at
> com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:852)
> at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:917)
> at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:924)
> at
> com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:714)
> at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3622)
> at
> com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
> at
> com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:927)
> at
> com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1566)
> at
> com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:175)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
> at
> com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
> at
> com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
> at
> com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
> at
> com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
> at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
> at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
> at
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
> at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
> at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
> Caused by: java.lang.IllegalStateException: Cannot forward. Response
> already committed.
> at
> com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:161)
> at
> com.sun.jersey.server.impl.container.servlet.RequestDispatcherWrapper.forward(RequestDispatcherWrapper.java:74)
> at
> com.sun.jersey.server.impl.container.servlet.JSPTemplateProcessor.writeTo(JSPTemplateProcessor.java:121)
>
> My LoginResource class is fairly simple:
> @Path("/login")
> public class LoginResource {
> private static final Logger logger =
> Logger.getLogger(LoginResource.class);
>
> @GET
> public Viewable get(){
> logger.info("inside get() of LoginResource");
> return new Viewable("/login/login.jsp",this);
> }
>
> Thanks
> Dinesh
>
>
> On Fri, Oct 9, 2009 at 10:15 PM, Dinesh Narayanan <ndchandar_at_gmail.com>wrote:
>
>> Hello,
>> I developed a small JAX-RS app that worked fine when deployed in Jetty.
>> Now when I try to deploy this in Websphere 7.0.0.3,
>>
>> I ran into the following issues
>> a) static files are not accessible even though I have the following entry
>> in web.xml
>> <filter>
>> <filter-name>JerseyFilter</filter-name>
>>
>> <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
>> <init-param>
>> <param-name>c/param-name>
>> <param-value>true</param-value>
>> </init-param>
>> <init-param>
>>
>> <param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
>> <param-value>true</param-value>
>> </init-param>
>> <init-param>
>>
>> <param-name>com.sun.jersey.config.property.packages</param-name>
>>
>> <param-value>com.brocade.webportal.common;com.brocade.webportal.myAccount.resource;com.brocade.webportal.myHome.resource</param-value>
>> </init-param>
>> <init-param>
>>
>> <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
>> <param-value>/(image|css|js|dojo)/.*</param-value>
>> </init-param>
>> </filter>
>> <filter-mapping>
>> <filter-name>JerseyFilter</filter-name>
>> <url-pattern>/*</url-pattern>
>> </filter-mapping>
>>
>> b) When I try to access uri "
>> http://localhost:9084/GuicyMyBrocadeWeb/login", it prefixes "/" by
>> default for certain resources ("
>> http://localhost:9084/GuicyMyBrocadeWeb/login/"). The wierd thing is that
>> this happens only for a few URIs. And this triggers two GET requests
>> i) one for "http://localhost:9084/GuicyMyBrocadeWeb/login" - Firebug
>> showed me 302 status
>> ii) one for "http://localhost:9084/GuicyMyBrocadeWeb/login/") - 404
>> status
>>
>>
>> Not sure if I need to set
>> 'com.ibm.ws.webcontainer.invokeFiltersCompatibility' to true in WAS 7.0.0.x.
>> Anyway setting it to true
>> also did not work. The logs indicate Jersey got initialized correctly.
>>
>> [10/9/09 21:57:45:575 PDT] 00000017 PackagesResou I Scanning for root
>> resource and provider classes in the packages:
>> com.brocade.webportal.common
>> com.brocade.webportal.myAccount.resource
>> com.brocade.webportal.myHome.resource
>> [10/9/09 21:57:45:591 PDT] 00000017 PackagesResou I Root resource
>> classes found:
>> class com.brocade.webportal.myHome.resource.MyHomeResource
>> class com.brocade.webportal.myAccount.resource.HelloWorldResource
>> class com.brocade.webportal.common.resource.LoginResource
>> class com.brocade.webportal.myAccount.resource.MyAccountResource
>> class com.brocade.webportal.common.resource.UserResource
>> class com.brocade.webportal.common.resource.MenuResource
>> [10/9/09 21:57:45:606 PDT] 00000017 PackagesResou I Provider classes
>> found:
>> [10/9/09 21:57:45:794 PDT] 00000017 WebApplicatio I Initiating Jersey
>> application, version 'Jersey: 1.1.2-ea 08/25/2009 04:39 PM'
>>
>>
>> Googling also did not help me much. Did somebody get Jersey up and running
>> on WAS 7.0. Help would be really appreciated here. I would really like to
>> use
>> Jersey for my new Apps
>>
>> Thanks
>> Dinesh
>>
>
>
>