You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bob Scaggs <rs...@vnet.net> on 2006/01/22 19:33:18 UTC

"java.io.IOException: Negative seek offset" while expanding .tar file

I am getting an error when I use the unzip task to expand a tar file created using the tar task.

Below is a sample of the code I am executing as well as the error I am recieving.

Can anyone help with this?

listing of build.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="TarTest" default="unTar" basedir=".">
 <property name="tardir" value="${basedir}/tar" />
 <property name="buildTemp" value="${basedir}/buildTemp" />
 <property name="TestFilesDir" value="${buildTemp}/TestFilesDir" />
 <property name="expandedFilesDir" value="${basedir}/expandedFiles" />

 <!-- expand the tar file -->
 <target name ="unTar"  depends="makeTar" >
  <unzip src="${tardir}/test.tar" dest="${TARdistributionDir}" />
 </target>

 <!-- create the tar file -->
 <target name ="makeTar" depends="buildTestFiles" >
  <mkdir dir="${tardir}"/>
  <tar destfile="${tardir}/test.tar" basedir="${buildTemp}" />
 </target>

 <!-- create some files -->
 <target name="buildTestFiles" depends="prepareDirs" >
  <concat destfile="${TestFilesDir}/file1.txt">This is file1</concat>
  <concat destfile="${TestFilesDir}/file2.txt">This is file2</concat>
  <concat destfile="${TestFilesDir}/file3.txt">This is file3</concat>
 </target>

 <!-- create reqrd dirs -->
 <target name="prepareDirs" >
  <mkdir dir="${tardir}"/>
  <mkdir dir="${buildTemp}"/>
  <mkdir dir="${TestFilesDir}"/>
  <mkdir dir="${expandedFilesDir}"/>
 </target>
</project>

Result of  "ant -verbose" using the above build file:

 C:\test>ant -verbose
 Apache Ant version 1.6.2 compiled on July 16 2004
 Buildfile: build.xml
 Detected Java version: 1.4 in: C:\Progra~1\IBM\Rational\SDP\6.0\runtimes\base_v6
 \_jvm\jre
 Detected OS: Windows XP
 parsing buildfile C:\test\build.xml with URI = file:///C:/test/build.xml
 Project base dir set to: C:\test
 Build sequence for target `unTar' is [prepareDirs, buildTestFiles, makeTar, unTa
 r]
 Complete build sequence is [prepareDirs, buildTestFiles, makeTar, unTar, ]

 prepareDirs:
     [mkdir] Created dir: C:\test\tar
     [mkdir] Created dir: C:\test\buildTemp
     [mkdir] Created dir: C:\test\buildTemp\TestFilesDir
     [mkdir] Created dir: C:\test\expandedFiles

 buildTestFiles:

 makeTar:
       [tar]  added as C:/test/tar/test.tar doesn't exist.
       [tar] TestFilesDir added as C:/test/tar/test.tar doesn't exist.
       [tar] TestFilesDir\file1.txt added as C:/test/tar/test.tar doesn't exist.
       [tar] TestFilesDir\file2.txt added as C:/test/tar/test.tar doesn't exist.
       [tar] TestFilesDir\file3.txt added as C:/test/tar/test.tar doesn't exist.
       [tar] Building tar: C:\test\tar\test.tar

 unTar:
 Property ${TARdistributionDir} has not been set
     [unzip] Expanding: C:\test\tar\test.tar into C:\test\${TARdistributionDir}

 BUILD FAILED
 C:\test\build.xml:10: Error while expanding C:\test\tar\test.tar
  at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:128)
  at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:92)
  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
  at org.apache.tools.ant.Task.perform(Task.java:364)
  at org.apache.tools.ant.Target.execute(Target.java:341)
  at org.apache.tools.ant.Target.performTasks(Target.java:369)
  at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
  at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
  at org.apache.tools.ant.Main.runBuild(Main.java:673)
  at org.apache.tools.ant.Main.startAnt(Main.java:188)
  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
 Caused by: java.io.IOException: Negative seek offset
  at java.io.RandomAccessFile.seek(Native Method)
  at org.apache.tools.zip.ZipFile.positionAtCentralDirectory(ZipFile.java(
 Compiled Code))
  at org.apache.tools.zip.ZipFile.populateFromCentralDirectory(ZipFile.jav
 a:235)
  at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:142)
  at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:117)
  ... 11 more
 --- Nested Exception ---
 java.io.IOException: Negative seek offset
  at java.io.RandomAccessFile.seek(Native Method)
  at org.apache.tools.zip.ZipFile.positionAtCentralDirectory(ZipFile.java(
 Compiled Code))
  at org.apache.tools.zip.ZipFile.populateFromCentralDirectory(ZipFile.jav
 a:235)
  at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:142)
  at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:117)
  at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:92)
  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
  at org.apache.tools.ant.Task.perform(Task.java:364)
  at org.apache.tools.ant.Target.execute(Target.java:341)
  at org.apache.tools.ant.Target.performTasks(Target.java:369)
  at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
  at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
  at org.apache.tools.ant.Main.runBuild(Main.java:673)
  at org.apache.tools.ant.Main.startAnt(Main.java:188)
  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

 Total time: 1 second


Re: "java.io.IOException: Negative seek offset" while expanding .tar file

Posted by glenn opdycke-hansen <gl...@gmail.com>.
hmm unzipping a tar file?  try untar.

RE: "java.io.IOException: Negative seek offset" while expanding .tar file

Posted by bill/wilandra <bi...@wilandra.com>.
I don't see TARdistributionDir being set to a value anywhere in the code you
provided. Is it set properly prior to the unTar target being run?

HTH Bill 

-----Original Message-----
From: Bob Scaggs [mailto:rscaggs@vnet.net] 
Sent: Sunday, January 22, 2006 10:33 AM
To: user@ant.apache.org
Subject: "java.io.IOException: Negative seek offset" while expanding .tar
file

I am getting an error when I use the unzip task to expand a tar file created
using the tar task.

Below is a sample of the code I am executing as well as the error I am
recieving.

Can anyone help with this?

listing of build.xml:

<?xml version="1.0" encoding="ISO-8859-1"?> <project name="TarTest"
default="unTar" basedir=".">  <property name="tardir" value="${basedir}/tar"
/>  <property name="buildTemp" value="${basedir}/buildTemp" />  <property
name="TestFilesDir" value="${buildTemp}/TestFilesDir" />  <property
name="expandedFilesDir" value="${basedir}/expandedFiles" />

 <!-- expand the tar file -->
 <target name ="unTar"  depends="makeTar" >
  <unzip src="${tardir}/test.tar" dest="${TARdistributionDir}" />  </target>

 <!-- create the tar file -->
 <target name ="makeTar" depends="buildTestFiles" >
  <mkdir dir="${tardir}"/>
  <tar destfile="${tardir}/test.tar" basedir="${buildTemp}" />  </target>

 <!-- create some files -->
 <target name="buildTestFiles" depends="prepareDirs" >
  <concat destfile="${TestFilesDir}/file1.txt">This is file1</concat>
  <concat destfile="${TestFilesDir}/file2.txt">This is file2</concat>
  <concat destfile="${TestFilesDir}/file3.txt">This is file3</concat>
</target>

 <!-- create reqrd dirs -->
 <target name="prepareDirs" >
  <mkdir dir="${tardir}"/>
  <mkdir dir="${buildTemp}"/>
  <mkdir dir="${TestFilesDir}"/>
  <mkdir dir="${expandedFilesDir}"/>
 </target>
</project>

Result of  "ant -verbose" using the above build file:

 C:\test>ant -verbose
 Apache Ant version 1.6.2 compiled on July 16 2004
 Buildfile: build.xml
 Detected Java version: 1.4 in:
C:\Progra~1\IBM\Rational\SDP\6.0\runtimes\base_v6
 \_jvm\jre
 Detected OS: Windows XP
 parsing buildfile C:\test\build.xml with URI = file:///C:/test/build.xml
Project base dir set to: C:\test  Build sequence for target `unTar' is
[prepareDirs, buildTestFiles, makeTar, unTa  r]  Complete build sequence is
[prepareDirs, buildTestFiles, makeTar, unTar, ]

 prepareDirs:
     [mkdir] Created dir: C:\test\tar
     [mkdir] Created dir: C:\test\buildTemp
     [mkdir] Created dir: C:\test\buildTemp\TestFilesDir
     [mkdir] Created dir: C:\test\expandedFiles

 buildTestFiles:

 makeTar:
       [tar]  added as C:/test/tar/test.tar doesn't exist.
       [tar] TestFilesDir added as C:/test/tar/test.tar doesn't exist.
       [tar] TestFilesDir\file1.txt added as C:/test/tar/test.tar doesn't
exist.
       [tar] TestFilesDir\file2.txt added as C:/test/tar/test.tar doesn't
exist.
       [tar] TestFilesDir\file3.txt added as C:/test/tar/test.tar doesn't
exist.
       [tar] Building tar: C:\test\tar\test.tar

 unTar:
 Property ${TARdistributionDir} has not been set
     [unzip] Expanding: C:\test\tar\test.tar into
C:\test\${TARdistributionDir}

 BUILD FAILED
 C:\test\build.xml:10: Error while expanding C:\test\tar\test.tar
  at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:128)
  at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:92)
  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
  at org.apache.tools.ant.Task.perform(Task.java:364)
  at org.apache.tools.ant.Target.execute(Target.java:341)
  at org.apache.tools.ant.Target.performTasks(Target.java:369)
  at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
  at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
  at org.apache.tools.ant.Main.runBuild(Main.java:673)
  at org.apache.tools.ant.Main.startAnt(Main.java:188)
  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
 Caused by: java.io.IOException: Negative seek offset
  at java.io.RandomAccessFile.seek(Native Method)
  at org.apache.tools.zip.ZipFile.positionAtCentralDirectory(ZipFile.java(
 Compiled Code))
  at org.apache.tools.zip.ZipFile.populateFromCentralDirectory(ZipFile.jav
 a:235)
  at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:142)
  at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:117)
  ... 11 more
 --- Nested Exception ---
 java.io.IOException: Negative seek offset
  at java.io.RandomAccessFile.seek(Native Method)
  at org.apache.tools.zip.ZipFile.positionAtCentralDirectory(ZipFile.java(
 Compiled Code))
  at org.apache.tools.zip.ZipFile.populateFromCentralDirectory(ZipFile.jav
 a:235)
  at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:142)
  at org.apache.tools.ant.taskdefs.Expand.expandFile(Expand.java:117)
  at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:92)
  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
  at org.apache.tools.ant.Task.perform(Task.java:364)
  at org.apache.tools.ant.Target.execute(Target.java:341)
  at org.apache.tools.ant.Target.performTasks(Target.java:369)
  at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
  at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
  at org.apache.tools.ant.Main.runBuild(Main.java:673)
  at org.apache.tools.ant.Main.startAnt(Main.java:188)
  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

 Total time: 1 second




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org