users@jaxb.java.net

Re: Different versions of QName class - follow up

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 21 Mar 2006 10:58:55 -0800

Kirill Grouchnikov wrote:
> The jsr173_1.0_api.jar contains the version of QName without
> serialVersionUID (in package javax.xml.namespace). The rt.jar of JDK
> 5.0_06 contains QName (in the same package) with serialVersionUID.

When you have a conflict between a class in rt.jar and a class in a jar
file on your classpath, rt.jar always wins, by the default Java class
loader delegation rule.

So when you see a loader constraints violated like this, it must be that
you are setting up a classloader that doesn't follow the parent-first
delegation rule. Such a classloader usually allows certain classes to be
loaded from the parent (for example you need to get java.lang.String
from rt.jar), and if so, you can usually fix them by tweaking that list
to include javax.xml.namespace.

> As i understand, the JAXB 2.0 compiled classes use the former version,
> while at runtime the class loader may decide to use the JRE version
> instead - i think this is what causes the LinkageError.

Compiling classes against one version of QName and using it against
another version of QName is not an issue, unless we generate code that
relies on serialVersionUID, which we don't.

Even if this is an issue, you'll get a different error, not "loader
constraints violated" error.

> Any reason why the QName classes are different and why JAXB 2.0 is not
> compiled against the JDK version? I know there's little time left until
> FCS but this seems like a serious issue.

I don't think the compilation vs the runtime difference is the problem,
for the reason I mentioned. JAXB RI is compilied against JDK 5.0 (in
fact it's very difficult not to!)

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com