Return-Path: Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 50909 invoked from network); 22 Feb 2001 04:27:04 -0000 Received: from unknown (HELO newton) (mail@63.69.231.48) by h31.sny.collab.net with SMTP; 22 Feb 2001 04:27:04 -0000 Received: from nick by newton with local (Exim 3.20 #1 (Debian GNU/Linux)) for cocoon-dev@xml.apache.org id 14VnLk-0001Hy-00; Thu, 22 Feb 2001 01:27:28 -0300 Date: Thu, 22 Feb 2001 01:27:28 -0300 From: =?us-ascii?Q?Nicol=E1s?= Lichtmaier To: cocoon-dev@xml.apache.org Subject: [C1] [patch] Standalone Cocoon gives NPE Message-ID: <20010222012728.C1731@debian.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.12i X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N In Engine.handler, Cocoon tries to get an OutputStream to write the outBuf data, but the dummy implementation provided by EngineWrapper returns null..! Did that ever worked? =) Anyway, here's the patch: Index: Cocoon.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v retrieving revision 1.21 diff -u -r1.21 Cocoon.java --- Cocoon.java 2001/01/18 22:43:45 1.21 +++ Cocoon.java 2001/02/22 04:24:16 @@ -269,7 +269,7 @@ String userAgent = null; String xml = null; String out = null; - PrintWriter writer = null; + OutputStream os = null; Configurations confs = null; if (argument.length == 0) @@ -305,10 +305,10 @@ EngineWrapper engine = new EngineWrapper(confs); if (out == null) - writer = new PrintWriter(System.out); + os = System.out; else - writer = new PrintWriter(new FileWriter(out), true); - engine.handle(writer, new File(xml)); + os = new FileOutputStream(out); + engine.handle(os, new File(xml)); } private static void usage() { Index: EngineWrapper.java =================================================================== RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/EngineWrapper.java,v retrieving revision 1.13 diff -u -r1.13 EngineWrapper.java --- EngineWrapper.java 2001/01/11 13:52:19 1.13 +++ EngineWrapper.java 2001/02/22 04:24:17 @@ -83,11 +83,11 @@ this.userAgent = (String)confs.get("user-agent"); } - public void handle(PrintWriter out, File pathToDocument) throws Exception { + public void handle(OutputStream out, File pathToDocument) throws Exception { this.engine.handle(new HttpServletRequestImpl(pathToDocument), new HttpServletResponseImpl(out)); } - public void handle(PrintWriter out, File documentPath, String document) throws Exception { + public void handle(OutputStream out, File documentPath, String document) throws Exception { this.engine.handle(new HttpServletRequestImpl(documentPath, document), new HttpServletResponseImpl(out)); } @@ -188,19 +188,33 @@ */ public class HttpServletResponseImpl implements HttpServletResponse { - private PrintWriter out; + private OutputStream out; - public HttpServletResponseImpl(PrintWriter out) { + public HttpServletResponseImpl(OutputStream out) { this.out = out; } public PrintWriter getWriter() throws IOException { - return this.out; + return new PrintWriter(new OutputStreamWriter(this.out)); } + + public ServletOutputStream getOutputStream() throws IOException { + return new ServletOutputStream() + { + public void write(int c) throws IOException + { + out.write(c); + } + public void write(byte[] b, int off, int len) + throws IOException + { + out.write(b,off,len); + } + }; + } public void setContentLength(int len) {} public void setContentType(String type) {} - public ServletOutputStream getOutputStream() throws IOException { return null; } public String getCharacterEncoding() { return null; } public void addCookie(Cookie cookie) {} public boolean containsHeader(String name) { return false; }