Return-Path: X-Original-To: apmail-cocoon-dev-archive@www.apache.org Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 73E857C8B for ; Thu, 1 Dec 2011 13:20:42 +0000 (UTC) Received: (qmail 9939 invoked by uid 500); 1 Dec 2011 13:20:42 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 9786 invoked by uid 500); 1 Dec 2011 13:20:41 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 9779 invoked by uid 99); 1 Dec 2011 13:20:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 13:20:41 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ap-cocoon-dev@m.gmane.org designates 80.91.229.12 as permitted sender) Received: from [80.91.229.12] (HELO lo.gmane.org) (80.91.229.12) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 13:20:34 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RW6Ye-0003yA-17 for dev@cocoon.apache.org; Thu, 01 Dec 2011 14:20:12 +0100 Received: from 178-16-145-98.obit.ru ([178.16.145.98]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Dec 2011 14:20:12 +0100 Received: from lagivan by 178-16-145-98.obit.ru with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Dec 2011 14:20:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: dev@cocoon.apache.org From: Ivan Lagunov Subject: Re: Nullpointer in ZipSerializer (cocoon 2.2) Date: Thu, 1 Dec 2011 13:14:24 +0000 (UTC) Lines: 123 Message-ID: References: <78B923726E7D59429936580CF127E943A192CD2E62@eu1rdcrdc1wx032.exi.nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 178.16.145.98 (Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2) X-Virus-Checked: Checked by ClamAV on apache.org Robby Pelssers nxp.com> writes: > > > Hi guys, >   > Just wanted to know if the issue in below thread has ever been fixed.  >   > http://web.archiveorange.com/archive/v/uRmkWnxszXP6g7Xuw33H >   > To shortly describe the use case: >   > http://cocoon.apache.org/2.1/userdocs/ziparchive-serializer.html >   > The zipserializer only allows either: > -          You specify a src  pointing to some cocoon pipeline using cocoon://   (Ideally it would also support the servlet: protocol as now I have to provide a façade in the calling cocoon block) > -          You specify inline content and the serializer >   > In a ideal world you should be able to use src in combination with the serializer because now I have to first include the content from a pipeline by using before calling > >   >   >   > I actually created some nice generic functionality to work around some issues: >   >   > ************************ FLOWSCRIPT *************************************** > function downloadImdsZip() { >     var entries = []; >     new Collection(cocoon.request.getParameterValues("id")).forEach(function(id){ >                 var entry = {"name": id + ".xml", "source": "cocoon://chemicalcontent/imds/" + id + ".xml", "serializer": "upload"}; >                 print('Adding entry [name=' + entry.name + ', source=' + entry.source + '] to ZIP archive.');          >                 entries.push(entry); >     }); >     var response = cocoon.response;                         >                 response.setHeader( >                     "Content-Disposition", >                     "attachment; filename=imds.zip" >                 );    >     cocoon.sendPage("zipArchive", {"entries": entries});  > } >   > ************************************************************************* > >   xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" >   xmlns:zip="http://apache.org/cocoon/zip-archive/1.0" >   xmlns:cinclude="http://apache.org/cocoon/include/1.0"> >   >   >     >       >         >           >             >                       >            >           >                        >            >         >       >     >   > > ************************************************************************* > >   >   >   > > ************************************************************************* >   > But I now am facing the same nullpointer exception as in the link above. >   > Anyone some usefull input on this matter? >   > Cheers, > Robby Pelssers >   > Hi Robby, Just want to share my fix with the community. The NullPointerException was caused by ZipArchiveSerializer (improper usage of a setter method). If you read javadocs, they'll tell you that you shouldn't provide null to setConsumer method. You can use the specific method to deinitialize consumer. Here is the patch: Index: src/main/java/org/apache/cocoon/serialization/ZipArchiveSerializer.java =================================================================== --- src/main/java/org/apache/cocoon/serialization/ZipArchiveSerializer.java (revision 1208405) +++ src/main/java/org/apache/cocoon/serialization/ZipArchiveSerializer.java (revision ) @@ -369,7 +369,7 @@ throw this.exception = new SAXException(ioe); } - super.setConsumer(null); + super.recycle(); this.selector.release(this.serializer); this.serializer = null; Best regards, Ivan Lagunov