Closed mukundkrishnan closed 3 years ago
could you provide a little more information? the whole stacktrace, and the code you are executing would be helpful. also, what file is causing the problem? one that you are extracting? or archiving?
Stacktrace: 2016-10-26 10:55:14 - Could not complete request java.lang.RuntimeException: file name is too long ( > 100 bytes) at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.handleLongName(TarArchiveOutputStream.java:687) at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.putArchiveEntry(TarArchiveOutputStream.java:280) at org.rauschig.jarchivelib.CommonsArchiver.createArchiveEntry(CommonsArchiver.java:232) at org.rauschig.jarchivelib.CommonsArchiver.writeToArchive(CommonsArchiver.java:212) at org.rauschig.jarchivelib.CommonsArchiver.writeToArchive(CommonsArchiver.java:215) at org.rauschig.jarchivelib.CommonsArchiver.writeToArchive(CommonsArchiver.java:215) at org.rauschig.jarchivelib.CommonsArchiver.writeToArchive(CommonsArchiver.java:215) at org.rauschig.jarchivelib.CommonsArchiver.writeToArchive(CommonsArchiver.java:215) at org.rauschig.jarchivelib.CommonsArchiver.writeToArchive(CommonsArchiver.java:194) at org.rauschig.jarchivelib.CommonsArchiver.create(CommonsArchiver.java:55) at org.rauschig.jarchivelib.ArchiverCompressorDecorator.create(ArchiverCompressorDecorator.java:55)
Extract of Code:
File toArchive = new File(fileToArchive);
String archivedLocation = "";
if (toArchive.exists() && toArchive.isDirectory()) {
Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String archiveFileName = ARTIFACT_PARTIAL_NAME + "_" + dateFormat.format(new Date());
File destination = new File(ARCHIVE_LOCATION);
LOGGER.debug("ArchiveName: {}, Destination: {}, Source: {}", archiveFileName, destination, toArchive.getName());
_**File archive = archiver.create(archiveFileName, destination, toArchive);**_
archivedLocation = archive.getPath();
The exception happens while trying to archive a file with path having more than 102 char length.
http://commons.apache.org/proper/commons-compress/tar.html is the article that explains the long file names and how to handle them.
Use LongPathTool software will solve the Issue.
I am getting the following error when I used jarchivelib. Based of what I have found out, the LONGFILE_POSIX has to be set. Is there any way I get this to work within the library?