NullPointerException在Weka中导入包时发生。

huangapple go评论71阅读模式
英文:

NullPointerException when importing a package in Weka

问题

我正在开发一个用Java编写的Weka插件,并使用weka/packages/templates来使用ant编译和创建包。看起来Weka在从GUI(工具>包管理器>文件/URL)导入包时使用weka.core.packageManagement.DefaultPackage类,因为当我尝试在Ubuntu的Weka 3.8.6中导入生成的zip文件时,出现了以下堆栈跟踪中的空指针异常:

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。有人可以帮助我理解是什么导致了这个错误以及如何修复它吗?

英文:

I am developing a plugin for Weka in Java, and I'm using the weka/packages/templates to compile and create the package with ant. It look like Weka using the weka.core.packageManagement.DefaultPackage class while importing the packages from the GUI (Tools>PacketManager>File/URL) because when I try to import the resulting zip file in Weka 3.8.6 for Ubuntu, I get a NullPointerException with the following stack trace:

java.lang.NullPointerException: Cannot invoke &quot;Object.toString()&quot; because the return value of &quot;weka.core.packageManagement.DefaultPackage.getPackageMetaDataElement(Object)&quot; is null
	at weka.core.packageManagement.DefaultPackage.getDependencies(DefaultPackage.java:252)
	at weka.core.WekaPackageLibIsolatingClassLoader.init(WekaPackageLibIsolatingClassLoader.java:147)
	at weka.core.WekaPackageLibIsolatingClassLoader.&lt;init&gt;(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)

I am using OpenJDK 11.0.18 on Ubuntu. Can someone help me understand what is causing this error and how to fix it?

答案1

得分: 1

在阅读Weka源代码后,我意识到这个错误是在Weka读取包所需的依赖项时发生的。在模板文件Descriptions.props中,即使没有提到,这意味着需要部分 "Dependencies" 也是必需的。

所以我添加了以下内容以解决问题:

# 依赖项(格式:packageName(版本号的相等/不相等)
Depends=weka (&gt;=3.7.12)
英文:

After reading Weka source code I realized that this error occur while Weka reading depencies needed by the package. In the template file Descriptions.props that mean the section "Dependencies" are required even if it's not mentioned.

So I add theses lines to fix the problems:

# Dependencies (format: packageName (equality/inequality version_number)
Depends=weka (&gt;=3.7.12)

huangapple
  • 本文由 发表于 2023年4月6日 22:48:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75950875.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定