[ 
https://issues.apache.org/jira/browse/CXF-5428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13933094#comment-13933094
 ] 

Patrick Decat commented on CXF-5428:
------------------------------------

On JBoss EAP 5 with CXF 2.6.13, the services list page generates an exception 
when serving the servicelist.css file:
{noformat}
java.lang.IllegalStateException: "getWriter()" has already been called for this 
response
        at 
org.apache.catalina.connector.Response.getOutputStream(Response.java:590)
        at 
org.apache.catalina.connector.ResponseFacade.getOutputStream(ResponseFacade.java:183)
        at 
org.apache.cxf.transport.servlet.servicelist.ServiceListGeneratorServlet.renderStyleSheet(ServiceListGeneratorServlet.java:174)
        at 
org.apache.cxf.transport.servlet.servicelist.ServiceListGeneratorServlet.service(ServiceListGeneratorServlet.java:89)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at 
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:164)
        at 
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:131)
        at 
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:266)
        at 
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:191)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at 
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:242)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at 
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
        at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at 
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
        at 
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
        at 
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
        at 
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at 
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
        at 
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:383)
        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
        at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
        at 
org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:385)
        at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
        at java.lang.Thread.run(Thread.java:662)
{noformat}

This is due to {{response.getOutputStream()}} being called after 
{{response.getWriter()}}:
{noformat:title=http://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/servicelist/ServiceListGeneratorServlet.java}
69     public void service(HttpServletRequest request,
…
86         PrintWriter writer = response.getWriter();
87         AbstractDestination[] destinations = 
destinationRegistry.getSortedDestinations();
88         if (request.getParameter("stylesheet") != null) {
89             renderStyleSheet(request, response);
90             return;
91         }
…
169     private void renderStyleSheet(HttpServletRequest request, 
HttpServletResponse response)
170         throws IOException {
171         response.setContentType("text/css; charset=UTF-8");
172         URL url = this.getClass().getResource("servicelist.css");
173         if (url != null) {
174             IOUtils.copy(url.openStream(), response.getOutputStream());
175         }
176     }
{noformat}

Hence the initial suggestion from the original reporter to move the 
{{response.getWriter();}} call.

Should I open a new issue?

Regards,
Patrick.

> Sevice list page default stylesheet is not effective
> ----------------------------------------------------
>
>                 Key: CXF-5428
>                 URL: https://issues.apache.org/jira/browse/CXF-5428
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.7.8
>            Reporter: ptma
>            Assignee: Sergey Beryozkin
>            Priority: Trivial
>              Labels: patch
>             Fix For: 2.6.12, 2.7.9, 3.0.0-milestone2
>
>
> Fix:
> Move line 86 
> PrintWriter writer = response.getWriter();
> to line 126
> Modify line 172
> URL url = this.getClass().getResource("servicelist.css");
> with 
> URL url = this.getClass().getResource("../servicelist.css");



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to