我正在开发一个Java的Weka插件,我使用Weka/packages/模板来编译和创建ant
包。它看起来像Weka使用了Weka .core. packagmanagement . defaultpackage类,同时从GUI (Tools> packketmanager>File/URL)导入包,因为当我尝试在Ubuntu的Weka 3.8.6中导入生成的zip文件时,我得到了一个NullPointerException,其中包含以下堆栈跟踪:
java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "weka.core.packageManagement.DefaultPackage.getPackageMetaDataElement(Object)" is null
at weka.core.packageManagement.DefaultPackage.getDependencies(DefaultPackage.java:252)
at weka.core.WekaPackageLibIsolatingClassLoader.init(WekaPackageLibIsolatingClassLoader.java:147)
at weka.core.WekaPackageLibIsolatingClassLoader.<init>(WekaPackageLibIsolatingClassLoader.java:126)
at weka.core.WekaPackageClassLoaderManager.addPackageToClassLoader(WekaPackageClassLoaderManager.java:369)
at weka.core.WekaPackageManager.initializeAndLoadUnofficialPackage(WekaPackageManager.java:2372)
at weka.core.WekaPackageManager.installPackageFromArchive(WekaPackageManager.java:2359)
at weka.gui.PackageManager$UnofficialInstallTask.doInBackground(PackageManager.java:780)
at weka.gui.PackageManager$UnofficialInstallTask.doInBackground(PackageManager.java:724)
at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
我在Ubuntu上使用OpenJDK 11.0.18。有人能帮助我了解是什么导致这个错误,以及如何解决它?
在阅读了Weka源代码后,我意识到当Weka读取包所需的依赖项时发生了这个错误。在模板文件Descriptions.props
中,这意味着部分&;Dependencies";是必需的,即使没有提到。
所以我添加这些行来解决问题:
# Dependencies (format: packageName (equality/inequality version_number)
Depends=weka (>=3.7.12)