users@jaxb.java.net

JAXB and Tomcat 5.0.19

From: Thomas Kunz <thomas.kunz_at_sit.fraunhofer.de>
Date: Fri, 25 Jun 2004 16:00:26 +0200

Hi!

I have a problem when using my jaxb-generated classes within a servlet.
I put my jaxb-generated classes (jar-file) and the jaxb-jars in
"webapps/my-app/WEB-INF/lib". When the servlet is running, I get a
ClassNotFoundException:

java.lang.ClassNotFoundException: com.sun.xml.bind.ContextFactory_1_0_1
        at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:575)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:72)
        at javax.xml.bind.ContextFinder.searchcontextPath(ContextFinder.java:229)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:149)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:281)


Then I put the jaxb-jars in %TOMCAT_HOME%/common/endorsed. Now the
classes are found but I get the following exception:

ava.lang.ClassCastException
        at ebsa.TableOfPoliciesFactory.unmarshall(Unknown Source)

When I put the jar-file with my jaxb-generated classes in the endorsed
directory, too, I get some other exception, but however this is no
solution since I want to deploy the classes as a webapplication.

I create the JAXBContext with an URLClassLoader and that seems to be the
problem:

URLClassLoader urlClassLoader = URLClassLoader.newInstance(urls);
ctx = JAXBContext.newInstance(packageList, urlClassLoader);

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?

Thanks!

Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net