Excepción de TrueZip lanzada al llamar al método CP_RP
Pregunta
Tengo un programa realmente simple en el que estoy tratando de agregar un directorio a un nuevo archivo zip. El código:
public class Encrypt {
public static void main(String[] args) {
TFile srcFile = new TFile(args[0]);
TFile destFile = new TFile("/home/myuser/archive.zip");
try {
TFile.umount();
} catch (FsSyncException e1) {
e1.printStackTrace();
}
try {
if (destFile.isArchive() || destFile.isDirectory())
destFile = new TFile(destFile, srcFile.getName());
srcFile.cp_rp(destFile);
} catch (IOException e) {
e.printStackTrace();
}
try {
TFile.umount();
} catch (FsSyncException e) {
e.printStackTrace();
}
}
}
Este es más o menos el código de aquí. La excepción:
Jun 17, 2011 12:10:26 PM de.schlichtherle.truezip.fs.sl.FsDriverLocator$Boot <clinit>
WARNING: No provider available for class de.schlichtherle.truezip.fs.spi.FsDriverService
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.util.ServiceConfigurationError: file (unknown file system scheme - check run time class path configuration)
at de.schlichtherle.truezip.file.TArchiveDetector.newController(TArchiveDetector.java:341)
at de.schlichtherle.truezip.fs.FsDefaultManager.getController(FsDefaultManager.java:75)
at de.schlichtherle.truezip.fs.FsDefaultManager.getController(FsDefaultManager.java:65)
at de.schlichtherle.truezip.fs.FsFailSafeManager.getController(FsFailSafeManager.java:59)
at de.schlichtherle.truezip.file.TBIO.getInputSocket(TBIO.java:291)
at de.schlichtherle.truezip.file.TBIO.cp0(TBIO.java:229)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:193)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r0(TBIO.java:183)
at de.schlichtherle.truezip.file.TBIO.cp_r(TBIO.java:154)
at de.schlichtherle.truezip.file.TFile.cp_rp(TFile.java:3161)
at Encrypt.main(Encrypt.java:38)
... 5 more
No puedo encontrar nada relacionado con esta excepción en la página del proyecto u otras páginas. ¿Alguien ha visto esto antes? Estoy usando TrueZip 7.1.4.
Solución
Correcto, hay dependencias de tiempo de ejecución en los módulos del controlador del sistema de archivos a los que desea acceder.
Por ejemplo, si desea acceder a archivos zip, debe tener los frascos de los módulos TrueZip Driver Zip (truezip-driver-zip
) y archivo del controlador TrueZip (truezip-driver-file
) en la ruta de clase de tiempo de ejecución.
Otros consejos
El problema era que faltaba una dependencia del frasco del proyecto: truezip-driver-file-jse7-7.2-beta-3.jar
. Puedes conseguirlo de aquí. Es bastante difícil encontrar todos los archivos necesarios.
Si está usando Maven, puede agregar lo siguiente dependencias en tu pom.xml
archivo, por ejemplo
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>de.schlichtherle.truezip</groupId>
<artifactId>truezip-driver-file</artifactId>
<version>7.7.10</version>
</dependency>
<dependency>
<groupId>de.schlichtherle.truezip</groupId>
<artifactId>truezip-file</artifactId>
<version>7.7.10</version>
</dependency>
<dependency>
<groupId>de.schlichtherle.truezip</groupId>
<artifactId>truezip-kernel</artifactId>
<version>7.7.10</version>
</dependency>
<dependency>
<groupId>de.schlichtherle.truezip</groupId>
<artifactId>truezip-driver-zip</artifactId>
<version>7.7.10</version>
</dependency>
</dependencies>
Entonces corre mvn clean install
Y debería funcionar.