On Thu, 31 Jan 2002, Luke Studley wrote:

> Date: Thu, 31 Jan 2002 17:00:02 -0000
> From: Luke Studley <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: 'Tomcat Users List' <[EMAIL PROTECTED]>
> Subject: RE: JAXB and Tomcat Problem
>
>
> Also I believe that JAXB will need to create your application classes (the
> ones created by the JAXB source generator) as it parses the XML input you
> read. So if you put JAXB in common/lib you will also have to put your
> application class files that are created by JAXB there also. This may be why
> it works when you have it in WEB-INF/lib.
>

This situation of code in the shared library creating application objects
whose classes are loaded from WEB-INF is a common one.  It can be dealt
with, in a servlet 2.3 environment, if the class doing the object creation
deliberately acquires the web application's class loader and uses it to
load application classes.  The container provides this class loader
through a mechanism called the "thread context class loader":

  ClassLoader webappClassLoader =
    Thread.currentThread().getContextClassLoader();
  Class webappClass =
    webappClassLoader.loadClass("comm.foo.bar.MyClass");

NOTE:  The availability of the webapp class loader in this way is only
guaranteed in a servlet 2.3 environment.  However, it is commonly
implemented by servlet 2.2 containers (such as Tomcat 3.x) as well.

> [Aside: Have they fixed that awful bug in JAXB yet that doesn't allow
> optional elements in the DTD? That made it unusable for me a few months
> ago.]
>
> Luke

Craig


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to