You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Frederick N. Brier" <fb...@multideck.com> on 2001/08/27 07:41:30 UTC

Classpath problem

Help me understand something.  commons-beanutils.jar, 
commons-collections.jar, commons-digester.jar, struts.jar are placed in my 
.war files WEB-INF/lib directory.  Everything is fine.  I additionally copy 
them into my JVM's classpath (in JBoss by copying them into the 
jboss/lib/ext directory) and my Action and Form classes generate 
java.lang.ClassNotFound exceptions.  Having them in just jboss/lib/ext and 
not the WEB-INF/lib also generates a java.lang.ClassNotFound 
exception.  Why?  Why does Struts care about where the .jar files are in 
the classpath?

My reason for wanting to do this was most of my .war files were going to be 
built on top of Struts.  There are also "base" utility classes that 
inherited from org.apache.struts.action.ActionForm and 
org.apache.struts.action.Action that most of my classes were going to 
inherit from.  They were going to go in a .jar file that were deployed to 
/jboss/lib/ext.  It didn't seem appropriate to have them all in each .war file.

Thank you.
Fred.


Re: Classpath problem

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 27 Aug 2001, Frederick N. Brier wrote:

> Date: Mon, 27 Aug 2001 01:41:30 -0400
> From: Frederick N. Brier <fb...@multideck.com>
> Reply-To: struts-user@jakarta.apache.org
> To: struts-user@jakarta.apache.org
> Subject: Classpath problem
>
> Help me understand something.  commons-beanutils.jar,
> commons-collections.jar, commons-digester.jar, struts.jar are placed in my
> .war files WEB-INF/lib directory.  Everything is fine.  I additionally copy
> them into my JVM's classpath (in JBoss by copying them into the
> jboss/lib/ext directory) and my Action and Form classes generate
> java.lang.ClassNotFound exceptions.  Having them in just jboss/lib/ext and
> not the WEB-INF/lib also generates a java.lang.ClassNotFound
> exception.  Why?  Why does Struts care about where the .jar files are in
> the classpath?

The reason has to do with the nitty gritty details of the way class
loaders work in Java -- but the bottom line is that if a class Foo needs
access to other classes that are in /WEB-INF/classes or /WEB-INF/lib, then
class Foo must *itself* be stored in /WEB-INF/classes or /WEB-INF/lib.

>
> My reason for wanting to do this was most of my .war files were going to be
> built on top of Struts.  There are also "base" utility classes that
> inherited from org.apache.struts.action.ActionForm and
> org.apache.struts.action.Action that most of my classes were going to
> inherit from.  They were going to go in a .jar file that were deployed to
> /jboss/lib/ext.  It didn't seem appropriate to have them all in each .war file.
>
> Thank you.
> Fred.
>
>

On the contrary, it's very appropriate -- the rationale is based on the
idea that web applications should be as *stand alone* as possible, and
include everything they need.

Craig