NullPointerException when importing a package in Weka

88 Views Asked by At

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

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

There are 1 best solutions below

1
Ottobus On

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 (>=3.7.12)