You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Spijker, Lodewijk" <ls...@Informatica.com> on 2003/10/31 11:25:01 UTC

Crash in AxisServlet when getting the list of services or getting the wsdl

Hi,
 
we have an application running on WebLogic81 (among others, like
WebSphere5, SunOne, WebLogic61, JBoss). We use Axis for handling SOAP.
When the application is installed you can get a list of all installed
webservices by the following URL: 
http://localhost:7001/ias/api4/services
<http://localhost:7001/ias/api4/services> , this crashes. Obtaining the
wsdl crashes too. Here the stacktrace:
 
Oct 24, 2003 4:50:06 PM CEST> <Error> <HTTP> <BEA-101020>
<[ServletContext(id=19282192,name=ias,context-path=/ias)] Ser
vlet failed with Exception
java.lang.IllegalStateException: Attempt to change ContentType after
calling getWriter() (cannot change charset from 'Cp1252' to
'ISO-8859-1')
       at
weblogic.servlet.internal.ServletResponseImpl.setEncoding(ServletRespons
eImpl.java:857)
       at
weblogic.servlet.internal.ServletResponseImpl.setHeader(ServletResponseI
mpl.java:688)
       at
weblogic.servlet.internal.ServletResponseImpl.setContentType(ServletResp
onseImpl.java:269)
       at
org.apache.axis.transport.http.AxisServlet.reportTroubleInGet(AxisServle
t.java:358)
       at
org.apache.axis.transport.http.AxisServlet.doGet(AxisServlet.java:340)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
       at
org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.j
ava:339)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
       at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Se
rvletStubImpl.java:1053)
       at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
java:387)
       at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.
java:305)
       at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.r
un(WebAppServletContext.java:6310)
       at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSu
bject.java:317)
       at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118
)
       at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServl
etContext.java:3622)
       at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.
java:2569)
       at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
       at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
 
.
 
I have examined the code of the AxisServlet.java and I noticed that a
PrintWriter object was created from the HttpServletResponse object.
However, after that, the content type of the response object was
changed. This is not recommended practice, but at least in case of
WebLogic81, it is prohibited (see stacktrace above).
The fix for this problem was rather easy. I have made a wrapper around
the PrintWriter class that creates the PrintWriter object on demand.
This has the advantage to the create writer try..finally..writer.close
construct can be left intact. It works because, fortunately, nowhere the
contenttype of the response object is changed after actually using the
writer.
 
To elaborate the above explanation, I have included the new
implementation of the AxisServlet.java and the printer writer class. You
are entitled to use this code as you see fit in axis.
 
I hope that it will helpful and prevents some problems with Axis and
WebLogic81,
 
regards,
 
Lodewijk Spijker
Software Engineer
Informatica Netherlands BV
 
lspijker@informatica.com