1

我想在服务器中使用 TrueZIP 7.7 库来解压缩用户上传的档案。我不打算使用加密档案,尤其是因为这是一个服务器,所以我不需要 Swing 弹出窗口来请求密钥。然而,当我为解压缩文件创建了一些简单的测试时,它因以下错误而失败:

java.util.ServiceConfigurationError: de.schlichtherle.truezip.key.spi.KeyManagerService: Provider de.schlichtherle.truezip.fs.archive.zip.raes.PromptingKeyManagerService could not be instantiated: java.lang.NoClassDefFoundError: de/schlichtherle/truezip/swing/EnhancedPanel
        at java.util.ServiceLoader.fail(ServiceLoader.java:207)
        at java.util.ServiceLoader.access$100(ServiceLoader.java:164)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
        at de.schlichtherle.truezip.key.sl.KeyManagerLocator$Boot.<clinit>(KeyManagerLocator.java:60)
        at de.schlichtherle.truezip.key.sl.KeyManagerLocator.get(KeyManagerLocator.java:41)
        at de.schlichtherle.truezip.key.AbstractKeyManagerProvider.get(AbstractKeyManagerProvider.java:22)
        at de.schlichtherle.truezip.fs.archive.zip.KeyController.getKeyManager(KeyController.java:62)
        at de.schlichtherle.truezip.fs.archive.zip.KeyController.sync(KeyController.java:129)
        at de.schlichtherle.truezip.fs.FsDecoratingController.sync(FsDecoratingController.java:131)
        at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.sync(FsFalsePositiveArchiveController.java:480)
        at de.schlichtherle.truezip.fs.FsManager.sync(FsManager.java:105)
        at de.schlichtherle.truezip.fs.FsDefaultManager.sync(FsDefaultManager.java:190)
        at de.schlichtherle.truezip.fs.FsSyncShutdownHook$Hook.run(FsSyncShutdownHook.java:93)
Caused by: java.lang.NoClassDefFoundError: de/schlichtherle/truezip/swing/EnhancedPanel
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at de.schlichtherle.truezip.fs.archive.zip.raes.PromptingKeyManagerService.<init>(PromptingKeyManagerService.java:37)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)
        ... 11 more
Caused by: java.lang.ClassNotFoundException: de.schlichtherle.truezip.swing.EnhancedPanel
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        ... 31 more

是否可以完全禁用 TrueZIP 密钥管理,或者至少确保它不需要任何 Swing 组件来提取 ZIP 文件?

4

1 回答 1

1

使用 TrueZIP,您必须满足 TrueZIP Driver ZIP 对 TrueZIP Swing 的依赖性,否则您将无法摆脱此异常。只要您的应用程序没有遇到 WinZip AES 加密条目,密钥管理器弹出窗口就不会出现。你也可以按照这篇文章实现你自己的密钥管理:http: //truezip.java.net/truezip-driver/truezip-driver-zip/key-management.html(但你仍然需要满足这个依赖)。

或者,您可以迁移到TrueVFS。TrueVFS 具有更加模块化的体系结构,您只需在类路径中添加TrueCommons KeyManager Disable模块即可获得相同的效果。

于 2013-08-10T11:44:26.663 回答