This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes End-of-central-directory signature not found during zip download Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "End-of-central-directory signature not found during zip download" Watch "End-of-central-directory signature not found during zip download" New topic

End-of-central-directory signature not found during zip download

Adrien Ruffie
Ranch Hand

Joined: Jan 14, 2009
Posts: 90
Hello everyone I have a problem during a zip file download.

I have a servlet which return the required file:

protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException{
// super.doGet(req, resp);
final String params = this.requestExtractor(req);
final File artifactDir = GeneralHelper.getArtifactsRepo();
final File artifactFile = new File(artifactDir, params);
final String[] splittedParams = params.split("/");

if (artifactFile.exists()) {
//resp.setContentType(new MimetypesFileTypeMap().getContentType(artifactFile));

resp.setHeader("Content-Disposition", "attachment; filename="
+ splittedParams[splittedParams.length - 1]);

final OutputStream out = resp.getOutputStream();
final FileInputStream in = new FileInputStream(artifactFile);

final String cacheControl = (String) ConfigHelper
resp.setHeader("Cache-Control", cacheControl); // HTTP 1.1
resp.setHeader("Pragma", cacheControl); // HTTP 1.0

final byte buffer[] = new byte[512 * 1024];
int nbLecture;

while ((nbLecture = != -1) {
out.write(buffer, 0, nbLecture);

} finally {

} else {
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource not found ["
+ splittedParams[splittedParams.length - 1] + "]");


I download it with "wget" under Ubuntu for example: wget http://localhost:9090/webapp/rest/artifacts/components/

But when I try a "unzip" for this file, its doesn't work :'( and the following message is displayed in Console:

End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of or, and cannot find, period.

Do you have an idea to resolve this problem ?



Adrien Ruffie
Ranch Hand

Joined: Jan 14, 2009
Posts: 90
Problem resolved, it was due to a security constraint affected to this servlet, in the web.xml
GeeCON Prague 2014
subject: End-of-central-directory signature not found during zip download