Java TrueZip:NoClassDefFoundError(但仅适用于关机挂钩?)
我有一个使用PhantomJS的项目。有一个插件将自动安装它:Java TrueZip:NoClassDefFoundError(但仅适用于关机挂钩?),java,maven,phantomjs,truezip,Java,Maven,Phantomjs,Truezip,我有一个使用PhantomJS的项目。有一个插件将自动安装它: <plugin> <groupId>com.github.klieber</groupId> <artifactId>phantomjs-maven-plugin</artifactId> <version>0.2.1</version> <executions>
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.2.1</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.9.2</version>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<systemPropertyVariables>
<phantomjs.binary>${phantomjs.binary}</phantomjs.binary>
</systemPropertyVariables>
</configuration>
</plugin>
添加这些(根据):
。。。因此只包含一个版本。如果您通过
java-jar
执行它,或者您的maven插件在提供的范围之外调用一个目标,请将依赖项的范围设置为compile我对PhantomJS不太了解,但是您认为异常是由关闭挂钩引发的。这个钩子是一个安全网,它通过TrueZIP将任何挂起的更改提交给归档文件。您可以通过在JVM终止之前调用de.schlichtherle.truezip.file.TVFS.umount()
轻松删除它。请在finally
-块中包装调用,以确保即使应用程序以可丢弃的方式终止,调用也会被调用。我可以通过将java版本从IBM java 1.7更改为IBM java 1.8(IBM_sdk_8.0.3.0)或Oracle java 1.8(jdk_1.8.0.91_64)来解决这个问题。您可以通过在终端或命令提示符中键入java-version
来检查java版本。OS=windows 10更改作用域不会删除错误。同时尝试了“编译”和“测试”。这也可能是一个类路径问题(我认为这就是问题的实质所在……):如何执行您的目标/运行应用程序?有趣的是,它只在运行“mvn清理测试”(也下载PhantomJS)时发生,而不是在运行“mvn测试”(然后已经安装了PhantomJS)时发生。那么,插件本身似乎有一个bug。PhantomJS插件本身可能有一些配置无法获取所需的依赖项。我应该将该调用放在哪里,因为它是一个导致异常开始的插件?我想你需要联系插件作者并告诉他们添加缺少的调用。他们那边没有,你对此无能为力。类似:。
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.665 s
[INFO] Finished at: 2015-07-07T13:27:39+02:00
[INFO] Final Memory: 31M/175M
[INFO] ------------------------------------------------------------------------
java.lang.NoClassDefFoundError: de/schlichtherle/truezip/fs/FsSyncOptions
at de.schlichtherle.truezip.fs.FsSyncShutdownHook$Hook.run(FsSyncShutdownHook.java:93)
Caused by: java.lang.ClassNotFoundException: de.schlichtherle.truezip.fs.FsSyncOptions
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
... 1 more
<dependency>
<!-- For the PhantomJS install plugin -->
<groupId>de.schlichtherle.truezip</groupId>
<artifactId>truezip-driver-file</artifactId>
<version>7.7.9</version>
</dependency>
<dependency>
<!-- For the PhantomJS install plugin -->
<groupId>de.schlichtherle.truezip</groupId>
<artifactId>truezip-kernel</artifactId>
<version>7.7.9</version>
</dependency>
<dependency>
<!-- For the PhantomJS install plugin -->
<groupId>de.schlichtherle.truezip</groupId>
<artifactId>truezip-driver-zip</artifactId>
<version>7.7.9</version>
</dependency>
$ mvn dependency:tree | grep truezip
[INFO] +- de.schlichtherle.truezip:truezip-driver-file:jar:7.7.9:compile
[INFO] +- de.schlichtherle.truezip:truezip-kernel:jar:7.7.9:compile
[INFO] +- de.schlichtherle.truezip:truezip-driver-zip:jar:7.7.9:compile
[INFO] | +- de.schlichtherle.truezip:truezip-swing:jar:7.7.9:compile