You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pierre Métras <ge...@sympatico.ca> on 2000/08/15 00:27:30 UTC

Should be simple: where to put struts.jar?

Hello,

I've installed STRUTS this week-end on tomcat 3.1 under linux. I've copied
the struts-example.war and struts-documentation.war under the
$TOMCAT/webapps, restarted tomcat and was able to play immediately with the
example.

Good! today, let's try STRUTS on my application. I select a simple
registration form quite similar with the example. I created the various
classes needed by my registration form, update my web.xml to reference the
servlets and struts.tld. Ready, go!

"org.apache.jasper.JasperException: unable to load class
org.apache.struts.taglib.MessageTag" at
org.apache.jasper.compiler.TagBeginGenerator.init (...:121).

That's not a ClassNotFoundException, but it looks like. I drop a look at the
source to see that the loader can't find the MessageTag.class. I checked my
web.xml file: seems correct. Then I added a reference to struts.jar in the
CLASSPATH, in case, restarted the server. Still the same message. I moved
struts.jar in the various directories WEB-INF, WEB-INF/lib,
WEB-INF/classes... without success.

Then I extracted the class files from struts.jar into WEB-INF/classes. This
error disappears to be replaced by a message resources not found
"org.apache.struts.action.MESSAGE"...

So, my question. Where should I place strust.jar to have it work? It does in
the example application. Where have I missed something?

Thanks for any hint.
Pierre Métras



Re: Should be simple: where to put struts.jar?

Posted by Craig McClanahan <Cr...@eng.sun.com>.
Luke Taylor wrote:

> Craig McClanahan wrote:
> >
> > The canonical place to put JAR files containing classes your application needs
> > is in the "WEB-INF/lib" directory of your application.  Alternatively, you can
> > put them on Tomcat's classpath and *not* in the WEB-INF/lib directory, and
> > these classes should be available to all web applications.  Having them both
> > places *should* still work -- but I've heard of intermittent issues there.
> >
>
> I've had some problems with getting the action class to load the
> resource (.properties) file for my application which I think may have
> been due to having an extra copy of the struts.jar file lying around
> (at least it appears to have gone away now that I've tied it down to
> the one in WEB-INF/lib).
>

You will definitely want Struts, or any other library JAR, in one place
(WEB-INF/lib) or the other (classpath), but *not* both.  The problem with the
"both" approach is that you have the same class names in both places, and the rules
for which one gets loaded first are not spec'd -- and containers vary.  For
example, Tomcat will load such classes (and property files) from the system class
path first, so any class or property file you've changed in WEB-INF/classes or
WEB-INF/lib is ignored if "struts.jar" is on the system classpath.

>
> Luke.
>

Craig



Re: Should be simple: where to put struts.jar?

Posted by Luke Taylor <lu...@freesurf.ch>.

Craig McClanahan wrote:
> 
> The canonical place to put JAR files containing classes your application needs
> is in the "WEB-INF/lib" directory of your application.  Alternatively, you can
> put them on Tomcat's classpath and *not* in the WEB-INF/lib directory, and
> these classes should be available to all web applications.  Having them both
> places *should* still work -- but I've heard of intermittent issues there.
> 

I've had some problems with getting the action class to load the
resource (.properties) file for my application which I think may have
been due to having an extra copy of the struts.jar file lying around
(at least it appears to have gone away now that I've tied it down to
the one in WEB-INF/lib).

Luke.


-- 
 Luke Taylor.
 PGP Key ID: 0x57E9523C

Re: Should be simple: where to put struts.jar?

Posted by Craig McClanahan <Cr...@eng.sun.com>.
Pierre Métras wrote:

> Hello,
>
> I've installed STRUTS this week-end on tomcat 3.1 under linux. I've copied
> the struts-example.war and struts-documentation.war under the
> $TOMCAT/webapps, restarted tomcat and was able to play immediately with the
> example.
>

Good :-)

>
> Good! today, let's try STRUTS on my application. I select a simple
> registration form quite similar with the example. I created the various
> classes needed by my registration form, update my web.xml to reference the
> servlets and struts.tld. Ready, go!
>
> "org.apache.jasper.JasperException: unable to load class
> org.apache.struts.taglib.MessageTag" at
> org.apache.jasper.compiler.TagBeginGenerator.init (...:121).
>
> That's not a ClassNotFoundException, but it looks like. I drop a look at the
> source to see that the loader can't find the MessageTag.class. I checked my
> web.xml file: seems correct. Then I added a reference to struts.jar in the
> CLASSPATH, in case, restarted the server. Still the same message. I moved
> struts.jar in the various directories WEB-INF, WEB-INF/lib,
> WEB-INF/classes... without success.
>
> Then I extracted the class files from struts.jar into WEB-INF/classes. This
> error disappears to be replaced by a message resources not found
> "org.apache.struts.action.MESSAGE"...
>
> So, my question. Where should I place strust.jar to have it work? It does in
> the example application. Where have I missed something?
>

The canonical place to put JAR files containing classes your application needs
is in the "WEB-INF/lib" directory of your application.  Alternatively, you can
put them on Tomcat's classpath and *not* in the WEB-INF/lib directory, and
these classes should be available to all web applications.  Having them both
places *should* still work -- but I've heard of intermittent issues there.

As to why the example app works with Tomcat 3.1 (it does for me too), but yours
doesn't, is something of a mystery ...

One thing you might want to try is updating to Tomcat 3.2beta2.  There have
been lots of improvements and bug fixes, and some of them related to Jasper's
ability to load classes.

>
> Thanks for any hint.
> Pierre Métras

Craig McClanahan