tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: log4j and CLASSPATH problems on linux
Date Sat, 03 Feb 2007 00:17:34 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oren,

Oren Livne wrote:
> 1. I tried to set up some useful libraries in directories outside
> $tomcat_home/lib but they were not recognized.

This isn't surprising. Tomcat expects to have full control over its own
classpath. You're better-off putting those libraries under
TOMCAT_HOME/common/lib, or TOMCAT_HOME/shared/lib. See
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html for the
details regarding the differences between these two.

> 2. I deployed a web application called "Catalog" to tomcat (it uses
> Struts 1.3.5 and Hibernate 3.2.1 GA), and placed log4.properties under
> webapps/Catalog/WEB-INF/classes. It is not recognized, and I get these
> warnings:
> 
> log4j:WARN No appenders could be found for logger
> (net.ruready.struts.filter.FindItemFilter).
> log4j:WARN Please initialize the log4j system properly.

Sometimes this message is emitted when a class tries to use log4j before
it is initialized (even though it will eventually be properly initialized).

> Also, I don't see any output although my log4j is configured to output
> messages.

That's unfortunate. I've never had good luck with log4j's automatic
configuration based on a properties file that it can find. Note that in
order for log4j to find the file in your classpath automagically, you'll
need to have log4j.jar in your webapp's WEB-INF/lib directory... if you
try to "share" your log4j library, nothing will work the way you expect
if you have more than one application using log4j.

Your best bet is to deploy log4j separately for each webapp. I usually
have a ServletContextListener that does something like this at startup,
along with anything else I need done at startup:

    // Trigger loading of the log4j.properties file from the classpath.
    new PropertyConfigurator();

> 3. When I run my app, it hangs trying to access the database. I have a
> hibernate.cfg.xml which works on windows, but once again,
> I am not sure what is going on because I don't see any log messages on
> linux.

Getting logging to work will certainly help debug this issue. Is it
hanging on the first db access? That could be anything. Is is hanging on
the second? It might be because you aren't properly cleaning up after
your connections (returning them to a connection pool?).

Your log4j.properties file looks good. Are you sure it's getting into
your webapp's WEB-INF/classes directory? If you develop in one directory
and then copy into your deploy directory, it's possible you may have
missed that particular file. Just checking.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFw9Se9CaO5/Lv0PARAsEOAJ0akhGW0wk6dPN60So85cpRenGSKQCaAn3n
4UH3g+bm6xNCxsQwTp9Y7VA=
=82Au
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message