• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

getWriter() has already been called for this response

Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to implement a servlet which returns xml after an example from Eben Hewitt: Java SOA Cookbook.
However I get an exception
WARNUNG: StandardWrapperValve[SimpleRestServlet]: PWC1406: Servlet.service() for servlet SimpleRestServlet threw exception
at de.pox.servlets.SimpleRestServlet.processRequest(SimpleRestServlet.java:59)
at de.pox.servlets.SimpleRestServlet.doGet(SimpleRestServlet.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

And I cannot figure out why.
Tested on glassfish 3.1 and JBoss 6.

Any help would be greatly appreciated.

Posts: 4568
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't call both getWriter() and getOutputStream() on the same response object, because they use the same underlying stream.

So you'll have to get rid of one of the calls. That doesn't look too hard, as you aren't really using the Writer for anything.
please buy this thing and then I get a fat cut of the action:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic