Working with the dnsjava library, I've encountered a frustrating and confusing problem where I can call Type.A
properly but calling Type.value(str)
throws a java.lang.NoClassDefFoundError
.
System.out.println(org.xbill.DNS.Type.A); // works
if (org.xbill.DNS.Type.value(type) == -1) { // throws NoClassDefFoundError
/* logic */
}
This code is being executed from a jar
and other classes in the jar use the library correctly.
Why and how could this be happening? How can I debug this further?
Thanks!
EDIT
Jon Skeet was correct. A friend showed me how to use javap -c
and I changed the value to something more distinct, Type.AAAA, which has a value of 28:
878: getstatic #116; //Field java/lang/System.out:Ljava/io/PrintStream;
881: bipush 28
It sounds like you're missing the dnsjava
library at execution time.
That doesn't matter for Type.A
because that's a constant - the value is being pulled out by the compiler and embedded directly into your code, as if you'd specified it as an integer literal. It doesn't need the library to be present at execution time. That's clearly not the case when you call a method though.