tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Loading classes from a WAR file outside of Tomcat
Date Thu, 26 Aug 2004 18:23:29 GMT

A WAR file is just a JAR file with special locations inside it.  The
Tomcat classloaders all extend which can read
from JARs.

So if you could open a WAR file and create a new URLClassLoader with the
URL to the WAR file's WEB-INF/classes directory, for example, you'd be
there.  The java.util.jar package has methods that get all almost all
the way there, but I think you might have to expand the WAR.

Yoav Shapira
Millennium Research Informatics

>-----Original Message-----
>From: Steve McWilliams []
>Sent: Thursday, August 26, 2004 2:19 PM
>Subject: Loading classes from a WAR file outside of Tomcat
>I am wondering if anyone can suggest an easy way to reuse WAR files
>outside of Tomcat.  We use Tomcat 5.0.27 and deliver out application
>bundled up in a WAR file, which we do not explode at runtime.
>Ideally I would like to be able to reuse some of the classes in our WAR
>file from a stand alone java application outside of Tomcat (that does
>administrative tasks and gets called by InstallShield at installation
>time).  I would rather not have to explode the WAR file to do this.
>I would like to be able to do something like this in my stand alone
>code, in order to find the class in the WAR file:
>WARClassLoader loader = new WARClassLoader();
>Class clazz = Class.forName(desiredClass, true, loader);
>I could write my own WARClassLoader, but it seems like such a thing
>already exist.  I poked around through the Tomcat source but everything
>seems to be snarled up in the Container and DirContext overhead
>I also looked at the Tomcat WebappLoader, StandardClassLoader, and
>WebappClassLoader but none of those look like they can read into a WAR
>Thanks in advance.
>Steve McWilliams
>Software Engineer
>Emprisa Networks
>The information contained in this communication is intended only for
>use of the recipient named above, and may be legally privileged,
>confidential and exempt from disclosure under applicable law. If the
>reader of this communication is not the intended recipient, you are
>notified that any dissemination, distribution or copying of this
>communication, or any of its contents, is strictly prohibited. If you
>received this communication in error, please resend this communication
>the sender and delete the original communication and any copy of it
>your computer system. Thank you.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message