Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: plexus-archiver
-
Labels:None
-
Environment:WinXP version 2002 SP1, jdk1.5.0b64, maven2
-
Number of attachments :
Description
While trying to add existing file to existing jar file (update mode), archiver throws error:
Caused by: org.codehaus.plexus.archiver.ArchiverException: Problem creating jar: Negative seek offset (and the archive is probably corrupt but I could not delete it) (and I couldn't rename the temporary file ip1185187450.tmp back)
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.createArchiveMain(AbstractZipArchiver.java:403)
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.createArchive(AbstractZipArchiver.java:229)
at com.db.gcf.gbcrm.maven2.plugins.Utils.pack(Utils.java:150)
... 21 more
Caused by: java.io.IOException: Negative seek offset
at java.io.RandomAccessFile.seek(Native Method)
at org.codehaus.plexus.archiver.zip.ZipFile.positionAtCentralDirectory(ZipFile.java:383)
at org.codehaus.plexus.archiver.zip.ZipFile.populateFromCentralDirectory(ZipFile.java:254)
at org.codehaus.plexus.archiver.zip.ZipFile.<init>(ZipFile.java:148)
at org.codehaus.plexus.archiver.zip.ZipFile.<init>(ZipFile.java:105)
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.getResourcesToAdd(AbstractZipArchiver.java:419)
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.createArchiveMain(AbstractZipArchiver.java:330)
... 23 more
Method I used:
/**
* Adds file or directory to given archive
* @param archiverManager that manages archivers
* @param aFile file or directory to pack
* @param aArchive archive to create or update
* @param update identifies if archive always created or existing archive is
* created
* @throws MojoExecutionException if any errors with file reading or writing
* occured
* @throws NoSuchArchiverException if archive extention does not have
* corresponding archiver
*/
public static void pack(ArchiverManager archiverManager, File aFile,
String aDestFileName, File aArchive, boolean update)
throws NoSuchArchiverException, MojoExecutionException {
String archiveExt = FileUtils.getExtension(aArchive.getAbsolutePath())
.toLowerCase();
try {
Archiver archiver = archiverManager.getArchiver(archiveExt);
if (archiver instanceof ZipArchiver) {
((ZipArchiver)archiver).setUpdateMode(update);
}
archiver.setDestFile(aArchive);
archiver.addFile(aFile, aDestFileName);
archiver.createArchive();
} catch (ArchiverException e) {
throw new MojoExecutionException("Error occured while packing file["
+ aFile + "] to archive[" + aArchive + "]", e);
} catch (IOException e) {
throw new MojoExecutionException("Error occured while packing file["
+ aFile + "] to archive[" + aArchive + "]", e);
}
}
Could not reproduce this issue.
I've attached a patch to the JarArchiverTest and copied some of your code in.
Maybe you could re-run your code or patch the Unit-Test and modify it in a way to proove this issue against the current version of plexus-archiver.