Bug 25163 - Unzip: java.io.IOException: Negative seek offset
Summary: Unzip: java.io.IOException: Negative seek offset
Status: RESOLVED INVALID
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.6.0
Hardware: PC All
: P3 critical (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-03 13:43 UTC by Jonny De Hertogh
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonny De Hertogh 2003-12-03 13:43:21 UTC
I have a textfile x.txt on a server:
SunOS aserver 5.9 Generic_112233-08 sun4us sparc FJSV,GPUS

I use gzip 1.3 (1999-12-21) to zip it. The file becomes x.txt.gz

Through FTP I download the file binary to my PC (Win 2000 Professional).

I run in a task only the following:
<unzip src="c:\jtemp\zipped\x.txt.gz" dest="c:\jtemp\unzipped"/>

When running only this task, I get:

C:\dvl.home\prj\ksz\build.xml:223: Error while expanding 
C:\jtemp\zipped\x.txt.gz
        at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:169)
        at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:133)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:302)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
--- Nested Exception ---
java.io.IOException: Negative seek offset
        at java.io.RandomAccessFile.seek(Native Method)
        at org.apache.tools.zip.ZipFile.positionAtCentralDirectory
(ZipFile.java:396)
        at org.apache.tools.zip.ZipFile.populateFromCentralDirectory
(ZipFile.java:274)
        at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:180)
        at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:158)
        at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:133)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:302)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)
Comment 1 Jonny De Hertogh 2003-12-03 13:59:36 UTC
The task gunzip works well in this case but I my situation I can't use gunzip 
because I want to use filesets: all the .gz-files in my directory have to be 
uncompressed.
Comment 2 peter reilly 2003-12-03 14:07:44 UTC
This is not a bug.
You are using the incorrect uncompression method.
You need to use <gunzip> instead of <unzip>.
<unzip> will think that this is a zip file and
not a gzip file.
Comment 3 peter reilly 2003-12-03 14:18:48 UTC
Ikkk.
You are right, the guzip task does not
take a fileset !
And one cannot set the compression method for
unzip or use the untar task.
Comment 4 peter reilly 2003-12-03 14:33:21 UTC
As a work-around (and when ant 1.6 beta3 comes out soon..)
you can use <for> from ant-contrib, (for is like foreach
but it uses macrodef instead of antcall so it is currently faster
for each iteration).
<project default="u" xmlns:ac="antlib:net.sf.antcontrib">
  <target name="u">
    <mkdir dir="unzipped"/>
    <ac:for param="file">
      <ac:path>
        <ac:fileset dir="${basedir}" includes="**/*.gz"/>
      </ac:path>
      <ac:sequential>
        <gunzip src="@{file}" dest="unzipped"/>
      </ac:sequential>
    </ac:for>
  </target>
</project>
Comment 5 Jonny De Hertogh 2003-12-04 13:40:32 UTC
Thanks for the quick answer. Quicker than the helpdesk of some paying 
software ;-)
But what do I have to install to make it work ?
I read and tried different things but it doesn't work. Probably I don't have 
enough knowledge of ant-contrib. But probably I am not alone and is it usefull 
to share it to others through these bug-comments...
Comment 6 peter reilly 2003-12-05 08:56:08 UTC
First for the <for> task, you need ant 1.6 beta3, just released.
Then you need a cvs version of ant-contrib, or take the lastest
gump compiled jar at http://gump.covalent.net/jars/latest/ant-contrib.
Place the ant-contrib.jar into the $ANT_HOME/lib directory.
You can then use the antlib namespace shortcut:
<project xmlns:ac="antlib:net.sf.antcontrib">
  <ac:for ...>
</project>
or use a <taskdef resource="net/sf/antcontrib/antcontrib.properties">
or <typedef resource="net/sf/antcontrib/antlib.xml"/> to access the
tasks without using namespaces.
Comment 7 Jonny De Hertogh 2003-12-05 11:18:02 UTC
Hoera, it works !

Thanks a lot !!!