Search code examples
javanoclassdeffounderrorvuze

Odd NoClassDefFoundError


After installing the latest version of Vuze (Azureus), I got an odd error trying to start it:

> java -Xmx128m -classpath ./Azureus2.jar:./swt.jar -Djava.library.path=/bt_work/vuze -Dazureus.install.path=/bt_work/vuze -Dazureus.script=./azureus -Dazureus.script.version=2 org.gudy.azureus2.ui.swt.Main
Exception in thread "main" java.lang.NoClassDefFoundError: org/gudy/azureus2/ui/swt/Main
Caused by: java.lang.ClassNotFoundException: org.gudy.azureus2.ui.swt.Main
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

What's odd is this:

> javap -classpath ./Azureus2.jar:./swt.jar org.gudy.azureus2.ui.swt.Main
Compiled from "Main.java"
public class org.gudy.azureus2.ui.swt.Main extends java.lang.Object{
    public static final java.lang.String PR_MULTI_INSTANCE;
...

So ... running javap with the same classpath finds the class but java alone can't. WTF is going on?

I checked that both programs come from the same install Java (/usr/lib64/jvm/java-1.6.0-sun), that's Java 6 and the classes were compiled for Java 5. The manifest isn't signed. The JAR file is readable (unzip -t reports no errors).


Solution

  • One word: AppArmor

    In my case, the config didn't allow the program java to load the JARs from the new installation path.

    If you have a similar problem, look into /var/log/audit.log. You should see the error messages there.