Question

I have a really simple program where I'm trying to add a directory to a new zip file. The code:

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();
        }
    }
}

This is pretty much the code from here. The exception:

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

I'm not able to find anything related to this exception on the project page or other pages. Has anyone seen this before? I'm using TrueZip 7.1.4.

Was it helpful?

Solution

Right, there are run time dependencies on the file system driver modules you want to access.

E.g. if you want to access ZIP files, you need to have the JARs of the modules TrueZIP Driver ZIP (truezip-driver-zip) and TrueZIP Driver File (truezip-driver-file) on the run time class path.

OTHER TIPS

The problem was there was a missing JAR dependency on the project: truezip-driver-file-jse7-7.2-beta-3.jar. You can get it from here. It's pretty hard to find all files needed.

If you're using Maven, you can add the following dependencies into your pom.xml file, e.g.

  <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>

Then run mvn clean install and it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top