users@jaxb.java.net

Re: JAXB and Tomcat 5.0.19

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 25 Jun 2004 08:39:45 -0700

> I create the JAXBContext with an URLClassLoader and that seems to be the
> problem:
>
> URLClassLoader urlClassLoader = URLClassLoader.newInstance(urls);
> ctx = JAXBContext.newInstance(packageList, urlClassLoader);

I'm not 100% sure, but I think your URLClassLoader has a wrong parent
class loader. Since you didn't specify the parent, the parent is the
system class loader, which doesn't delegate to your web-app's class
loader.

But looking at your code, your web-app's class loader seems to be
capable of loading JAXB APIs. So chances are, you are getting two copies
of the same classes, causing all sorts of weird problems.

> In an other servlet I create the JAXBContext without specifying a
> classloader - ctx = JAXBContext.newInstance(packageList) - and it works.
>
> As a standalone application, my application with creating the
> JAXBContext using an URLClassLoader also works fine.
>
> Has anybody some ideas how I can instantiate the JAXBContext with an
> URLClassLoader within a servlet?

Use which4j (http://which4j.dev.java.net/) and find out which class is
loaded from where. Make sure you don't have two copies of the same class
in different class loaders.

regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net