SmartDataAnalytics / DL-Learner

A tool for supervised Machine Learning in OWL and Description Logics
http://dl-learner.org
GNU General Public License v3.0
152 stars 34 forks source link

Build fails with NoClassDefFound for unife.bundle.bdd.BDDFactory2 #51

Closed bencomp closed 6 years ago

bencomp commented 8 years ago

When I run mvn clean install on the top level project, the build fails in the components-ext module with the following message (excerpt):

Tests run: 3, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 30.852 sec <<< FAILURE! - in org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAPTest
testCase1(org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAPTest)  Time elapsed: 10.306 sec  <<< ERROR!
java.lang.ExceptionInInitializerError: null
    at unife.bundle.bdd.BDDFactory2.<clinit>(BDDFactory2.java:61)
    at unife.edge.EDGE.init(EDGE.java:846)
    at org.dllearner.algorithms.probabilistic.parameter.unife.edge.EDGE.start(EDGE.java:96)
    at org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAP.greedySearch(LEAP.java:212)
    at org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAP.start(LEAP.java:103)
    at org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAPTest.testCase1(LEAPTest.java:93)

testCase2(org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAPTest)  Time elapsed: 10.28 sec  <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class unife.bundle.bdd.BDDFactory2
    at unife.edge.EDGE.init(EDGE.java:846)
    at org.dllearner.algorithms.probabilistic.parameter.unife.edge.EDGE.start(EDGE.java:96)
    at org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAP.greedySearch(LEAP.java:212)
    at org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAP.start(LEAP.java:103)
    at org.dllearner.algorithms.probabilistic.structure.unife.leap.LEAPTest.testCase2(LEAPTest.java:125)

Results :

Tests in error: 
  LEAPTest.testCase1:93 » ExceptionInInitializer
  LEAPTest.testCase2:125 » NoClassDefFound Could not initialize class unife.bund...

Tests run: 5, Failures: 0, Errors: 2, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] DL Learner Parent Pom .............................. SUCCESS [  0.687 s]
[INFO] DL Learner Core Components ......................... SUCCESS [02:34 min]
[INFO] components-ext ..................................... FAILURE [ 57.257 s]
[INFO] dllearner-interfaces ............................... SKIPPED
[INFO] interfaces-ext ..................................... SKIPPED
[INFO] Executable scripts ................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:32 min
[INFO] Finished at: 2016-10-13T21:14:18+02:00
[INFO] Final Memory: 69M/888M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project components-ext: There are test failures.

Is there a missing (external) dependency? bundle-2.2.jar is in my Maven local repository.

LorenzBuehmann commented 8 years ago

I cannot reproduce the problem. Neither on the master branch nor the develop branch I'm getting this error.

The dependencies should be loaded from the repository defined in the POM: https://github.com/AKSW/DL-Learner/blob/master/components-ext/pom.xml#L280-L307

I checked the bundle-2.2.jar in my local repository, and it contains the class BDDFactory2. It seems that something goes wrong in the initialization of this class, see the source code which contains this static class block:

static {
        try {
            String ex = getProperty("user.dir", ".") + getProperty("file.separator", "/");
            String var11 = "/bdd-libraries/lib";
            URL var12 = BDDFactory2.class.getResource(var11);
            String var13 = var12.getFile();
            String var14 = var13.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", "");
            JarFile var15 = new JarFile(var14);
            Enumeration entries = var15.entries();

            while(entries.hasMoreElements()) {
                JarEntry entry = (JarEntry)entries.nextElement();
                String entryName = "/" + entry.getName();
                if(entryName.startsWith(var11) && entryName.length() > var11.length() + "/".length() && entryName.substring(entryName.length() - ".so".length()).equals(".so")) {
                    String var9 = LoadNativeLibrary.createTempFile(entryName, ex).getName();
                }
            }
        } catch (IOException var10) {
            logger.error("Unable to load the Native Library.\n JDD will be used!");
            logger.error(var10.getMessage());
            StackTraceElement[] stack = var10.getStackTrace();
            StackTraceElement[] f = stack;
            int libraryDir = stack.length;

            for(int jarPath = 0; jarPath < libraryDir; ++jarPath) {
                StackTraceElement se = f[jarPath];
                logger.error(se.toString());
            }
        }

    }
bencomp commented 8 years ago

Thanks for your quick response!

When I debug testCase2 in IntelliJ IDEA a NullPointerException in the line String var13 = var12.getFile(); is said to cause the ExceptionInInitializer. There is no directory /bdd-libraries/lib on my system, so var12 will be null after the assignment.

Did you install BuDDy locally by any chance, preventing the NullPointerException?

LorenzBuehmann commented 8 years ago

No, I did nothing but using Maven. Giuseppe Cota, the developer of BUNDLE is looking into it.

giuseta commented 8 years ago

Hi bencomp, I cannot reproduce the problem me either. Just a silly question. What OS are you using? 32 or 64 bits? Windows or Linux?

bencomp commented 8 years ago

@giuseta I'm on Mac OSX, which is 64 bit. To be more complete:

$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_102, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"

$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
LorenzBuehmann commented 8 years ago

@giuseta Maybe there is a problem resp. a difference on MacOSX with Java and the system properties which are used to build the path. @bencomp Can you check if the *.so files are contained in the JAR file?

giuseta commented 8 years ago

Ok. In /bdd-libraries/lib there should be some shared libraries that are automatically downloaded by means of Maven. The problem here is that there are not shared libraries for MacOSX in the Maven repository that contains these BDD libraries. I'll compile the libraries for MacOSX and add them into the repository as soon as possible.

bencomp commented 8 years ago

@giuseta thanks for investigating and providing the solution!

giuseta commented 8 years ago

@bencomp I've found the libraries that you need for OSX but I'm not sure whether they work (Unfortunately I'm quite sure they are 32-bit libraries, I've downloaded them from here: http://javabdd.sourceforge.net/) . I don't own a Mac and I'm trying to crosscompile on linux in order to be sure to have 64-bit libraries for OSX, but I'm encountering some difficulties, so please try again to compile DL-Learner and let me know if it works.

giuseta commented 8 years ago

I worked around the issue by using a 100% Java BDD Factory in case the libraries are not correctly loaded. The performances are slightly worse when performing probabilistic reasoning but you should not have problems.

bencomp commented 8 years ago

@giuseta great :) I had found that JavaBDD library too, which said I need CUDD to build. When I downloaded and built CUDD on my machine, I ended up with libcudd.a and libcudd.la.

The Mac OSX binary distribution of JavaBDD indeed includes libbuddy.jnilib, but when I build JavaBDD from source I get libbdd.0.0.0.dylib. It looks like version management was lost since 2005 :(

A pure Java solution is a safe alternative, thanks for that. This was a change in BUNDLE, correct? Will you release this change and should DL-Learner release a new (minor) minor with the new version of BUNDLE as an updated dependency? Then this issue can be resolved with the next version.

giuseta commented 8 years ago

@bencomp You are correct, the change was in BUNDLE. I've already released this change. You should already be able to build DL-Leaner without changing anything

LorenzBuehmann commented 8 years ago

@giuseta Did you increase the version number of the BUNDLE artifact? Otherwise, @bencomp has to force an Maven update with mvn -U ... because this dependency isn't a SNAPSHOT.

giuseta commented 8 years ago

@LorenzBuehmann You are right, I didn't increase the version of BUNDLE artifact. He has to force Maven to update. Thank you for pointing that out.