Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
On Wed, May 05, 2010 at 08:31:33AM -0500, Caldarale, Charles R wrote: As always, don't put Context elements in server.xml. The above got you double deployment of the foo webapp, once as foo, once as the default. Why do people invite problems when it's so easy to do things properly? Maybe because the documentation doesn't say it's improper; it says you can do this. Your advice in this matter makes good sense when you explain it, but nobody sees it until he runs into a problem and brings it here. I think a documentation update from you would be widely appreciated, and save you loads of time in the long run. -- Mark H. Wood, Lead System Programmer mw...@iupui.edu Balance your desire for bells and whistles with the reality that only a little more than 2 percent of world population has broadband. -- Ledford and Tyler, _Google Analytics 2.0_ pgpRwq5u3Yj8X.pgp Description: PGP signature
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Mark H. Wood [mailto:mw...@iupui.edu] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Maybe because the documentation doesn't say it's improper; The current documentation for Context states (in bold): For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place Context elements directly in the server.xml file. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
On 05/05/2010 02:24, Caldarale, Charles R wrote: From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Scenario 1: log4j.jar is in Tomcat/lib directory log4j.jar is NOT in WEB-INF/lib directories Have you added *anything* else to Tomcat's lib directory? Scenario 3: log4j.jar is in Tomcat/lib directory log4j.jar is in WEB-INF/lib directories You must never have the same classes located in more than one spot in a given branch of the classloader tree, so the above is not a valid configuration. @joe Have you cleared out the tomcat/work directory? p - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org signature.asc Description: OpenPGP digital signature
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
. /mde/ --- On Tue, 5/4/10, Joe Hansen joe.hansen...@gmail.com wrote: From: Joe Hansen joe.hansen...@gmail.com Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory To: Tomcat Users List users@tomcat.apache.org Date: Tuesday, May 4, 2010, 4:55 PM This thread has grown too long. For anyone following this thread, here's the summary: Two web applications, each with a Virtual Host entry in server.xml file. Tomcat/webapps-abc Tomcat/webapps-xyz These two web applications have different log4j.properties files. These log4j property files log to different log files (Tomcat/logs/abc.log and Tomcat/logs/xyz.log). Tomcat/webapps-abc/ROOT/WEB-INF/classes/log4j.properties Tomcat/webapps-xyz/ROOT/WEB-INF/classes/log4j.properties The web applications abc and xyz using Java Commons Logging API (Log and LogFactory classes) to perform logging. Scenario 1: log4j.jar is in Tomcat/lib directory log4j.jar is NOT in WEB-INF/lib directories Result: abc webapp's log entries are written to xyz.log file Scenario 2: log4j.jar is NOT in Tomcat/lib directory log4j.jar is in WEB-INF/lib directories Result: ClassNotFoundError in Tomcat/logs/catalina.log files Scenario 3: log4j.jar is in Tomcat/lib directory log4j.jar is in WEB-INF/lib directories Result: Empty abc.log and xyz.log files. Here's the relevant portion of the webapps-abc/ROOT/WEB-INF/web.xml file: listener listener-classorg.springframework.web.util.Log4jConfigListener/listener-class /listener context-param param-namelog4jConfigLocation/param-name param-value/WEB-INF/classes/log4j.properties/param-value /context-param context-param param-namelog4jExposeWebAppRoot/param-name param-valuefalse/param-value /context-param listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener webapps-xyz/ROOT/WEB-INF/web.xml file looks just the same /* webapps-abc/ROOT/WEB-INF/classes/log4j.properties */ log4j.rootLogger=INFO, A2 log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A2.File=c:/Tomcat6/logs/abc.log log4j.appender.A2.MaxFileSize=100KB log4j.appender.A2.MaxBackupIndex=4 /* webapps-xyz/ROOT/WEB-INF/classes/log4j.properties */ log4j.rootLogger=INFO, A1 log4j.appender.A1=org.apache.log4j.RollingFileAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A1.File=c:/Tomcat6/logs/xyz.log log4j.appender.A1.MaxFileSize=100KB log4j.appender.A1.MaxBackupIndex=4 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
That was a nice and concise write-up, well-worth of an article in the Tomcat FAQ/WIKI. How to setup Tomcat with 3 virtual hosts, each with its own homepage and Manager (and other) applications, and its own logfiles. My only minor remark : Mark Eggers wrote: ... Finally for my setup, I added 127.0.0.1 foo and 127.0.0.1 bar to my hosts file in WINNT\system32\drivers\etc (this is an upgraded Windows/2000 Professional machine). Upon starting up this mess, /***/ all three hosts were visible at localhost:8080, foo:8080, and bar:8080 as you would expect. At the /***/, I would insert from a browser running on the same machine. Nothing to do with Tomcat really, but there are still quite a number of people out there confused by hostname lookup and IP routing stuff. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
I was having a similar problem moving a Tomcat 5.5 configuration to 6.0. Following this thread and reading the docs I created virtual hosts using the same webapps dir (it is a development environment with CVS and I would have to change many things to accomplish one webapp folder per virtual host). Using the examples on this thread it would be like this Host name=localhost appBase=webapps unpackWARs=true autoDeploy=false deployOnStartup=false xmlValidation=false xmlNamespaceAware=false /Host Host name=foo appBase=webapps unpackWARs=true autoDeploy=false deployOnStartup=false xmlValidation=false xmlNamespaceAware=false Context path= docBase=foo reloadable=true / /Host Host name=bar appBase=webapps unpackWARs=true autoDeploy=false deployOnStartup=false xmlValidation=false xmlNamespaceAware=false Context path= docBase=bar reloadable=true / /Host with this I avoid full apps initialization on Tomcat Startup (I have up to 20 and use !-- -- to comment the Host I am not workin on) and I am able to treat each app under webapps as an independent host. I suppose it is not a good set-up for a production environment but I needed a quick set-up to start working ASAP and this seems to work just fine. On Wed, May 5, 2010 at 10:57 AM, André Warnier a...@ice-sa.com wrote: That was a nice and concise write-up, well-worth of an article in the Tomcat FAQ/WIKI. How to setup Tomcat with 3 virtual hosts, each with its own homepage and Manager (and other) applications, and its own logfiles. My only minor remark : Mark Eggers wrote: ... Finally for my setup, I added 127.0.0.1 foo and 127.0.0.1 bar to my hosts file in WINNT\system32\drivers\etc (this is an upgraded Windows/2000 Professional machine). Upon starting up this mess, /***/ all three hosts were visible at localhost:8080, foo:8080, and bar:8080 as you would expect. At the /***/, I would insert from a browser running on the same machine. Nothing to do with Tomcat really, but there are still quite a number of people out there confused by hostname lookup and IP routing stuff. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Mark Eggers [mailto:its_toas...@yahoo.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Note that I do not have any non-Tomcat jar in apache-tomcat-6.0.26 besides JDBC jars at this point. Which I suspect is key to solving the OP's problem. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Nuno Faria [mailto:nuno.m.fa...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Following this thread and reading the docs I created virtual hosts using the same webapps dir That's a really, really bad idea - the hosts can easily scribble on each other when expanding war files. Don't do it, even in development. (it is a development environment with CVS and I would have to change many things to accomplish one webapp folder per virtual host). Much better to spend the effort up front to do things the right way than have to always wonder if the cause of strange behavior is due to having an invalid configuration. Context path= docBase=foo reloadable=true / As always, don't put Context elements in server.xml. The above got you double deployment of the foo webapp, once as foo, once as the default. Why do people invite problems when it's so easy to do things properly? Context path= docBase=bar reloadable=true / Same comment as above. with this I avoid full apps initialization on Tomcat Startup No, you don't - each app has to be initialized for each Host (or in your case, multiple times for each Host). All you might have avoided is expanding the .war files, which for development purposes you didn't need in the first place. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Mark Eggers [mailto:its_toas...@yahoo.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory I just hacked together a quick example on Windows/XP Professional. That was a nice and concise write-up, well-worth of an article in the Tomcat FAQ/WIKI. I strongly second André's comment. If it's not possible for you to put this in the FAQ, may one of us do it for you? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Mark, Chuck, Andre, and Charles, You guys rock! Mark, I followed your recommendations and 1. I copied the virtual host webapps directories outside Tomcat. c:/hosts/abc.local/webapps c:/hosts/xyz.local/webapps 2. Copied the manager.xml to Tomcat/conf/Catalina/abc.local and Tomcat/conf/Catalina/xyz.local. Also copied the manager web application to c:/hosts/abc.local/webapps and c:/hosts/xyz.local/webapps 3. I commented the following segment from abc.local/ROOT/WEB-INF/web.xml file !-- listener listener-classorg.springframework.web.util.Log4jConfigListener/listener-class /listener context-param param-namelog4jConfigLocation/param-name param-value/WEB-INF/classes/log4j.properties/param-value /context-param context-param param-namelog4jExposeWebAppRoot/param-name param-valuefalse/param-value /context-param -- 4. Removed log4j.jar from Tomcat/lib directory and copied it to abc.local/webapps/ROOT/WEB-INF/lib and xyz.local/webapps/ROOT/WEB-INF/lib I then restarted Tomcat. This DID NOT solve the issue complete though. The MOST IMPORTANT step was to move all jar files EXCEPT THE FOLLOWING jar files to WEB-INF/lib directory from Tomcat/lib directory: annotations-api.jar catalina.jar catalina-*.jar commons-dbcp.jar commons-pool.jar el-api.jar jasper*.jar jsp-api.jar mail.jar servlet-api.jar tomcat*.jar DATABASE-DRIVERS.jar As previously thought, the Quartz jobs (that run every one hour) were not part of the problem! I could not have resolved this issue without your contribution! I am very grateful for your kind help. :) Thank you all! - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Hey all, We are using Tomcat 6 on a Windows XP box. We have a web application named abc. It was initially in the c:\Tomcat\webapps directory. I then moved the c:\Tomcat\webapps\abc directory to c:\Tomcat\abc. I then changed the Tomcat/conf/server.xml file to reflect this change... Host name=abc.local appBase=abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path= docBase= ResourceLink global=jdbc/MySqlDatabase name=jdbc/MySqlDatabase type=javax.sql.DataSource / /Context /Host Though the web application itself works fine, the web application logging no longer works after this change! How do I get the log4j logging to work again? Please advice! Thank you, Joe log4j-1.2.15.jar file is in c:\Tomcat\lib directory log4j.properties file is in c:\Tomcat\abc\WEB-INF\classes directory /* Here's the c:\Tomcat\abc\WEB-INF\classes\log4j.properties directory */ log4j.rootLogger=INFO, A2 log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A2.File=c:/Tomcat6/logs/abc.log log4j.appender.A2.MaxFileSize=100KB log4j.appender.A2.MaxBackupIndex=4 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
On 04/05/2010 17:32, Joe Hansen wrote: Hey all, We are using Tomcat 6 on a Windows XP box. We have a web application named abc. It was initially in the c:\Tomcat\webapps directory. I then moved the c:\Tomcat\webapps\abc directory to c:\Tomcat\abc. I then changed the Tomcat/conf/server.xml file to reflect this change... Host name=abc.local appBase=abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path= docBase= ResourceLink global=jdbc/MySqlDatabase name=jdbc/MySqlDatabase type=javax.sql.DataSource / /Context /Host Though the web application itself works fine, the web application logging no longer works after this change! How do I get the log4j logging to work again? Please advice! Put the web application back where it belongs. docBase==appBase is *not* a valid configuration. As you have seen, things break if you do that. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Thank you for the super quick reply Mark! We are using Java Spring. The reason for moving the web application out of the webapps directory was that the Spring Context Loader was loading twice. First because its in the webapps directory. Secondly, because it is being referred to by the Host entry in the server.xml file. So how do I keep the web application out of Tomcat/webapps directory make the docBase different from the appBase? Or is there a way to keep the web application in the Tomcat/webapps directory and NOT have Spring Context Loader load twice. Please advice. Thanks, Joe On Tue, May 4, 2010 at 10:36 AM, Mark Thomas ma...@apache.org wrote: On 04/05/2010 17:32, Joe Hansen wrote: Hey all, We are using Tomcat 6 on a Windows XP box. We have a web application named abc. It was initially in the c:\Tomcat\webapps directory. I then moved the c:\Tomcat\webapps\abc directory to c:\Tomcat\abc. I then changed the Tomcat/conf/server.xml file to reflect this change... Host name=abc.local appBase=abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path= docBase= ResourceLink global=jdbc/MySqlDatabase name=jdbc/MySqlDatabase type=javax.sql.DataSource / /Context /Host Though the web application itself works fine, the web application logging no longer works after this change! How do I get the log4j logging to work again? Please advice! Put the web application back where it belongs. docBase==appBase is *not* a valid configuration. As you have seen, things break if you do that. Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
On 04/05/2010 17:43, Joe Hansen wrote: Thank you for the super quick reply Mark! We are using Java Spring. The reason for moving the web application out of the webapps directory was that the Spring Context Loader was loading twice. First because its in the webapps directory. Secondly, because it is being referred to by the Host entry in the server.xml file. So how do I keep the web application out of Tomcat/webapps directory make the docBase different from the appBase? Or is there a way to keep the web application in the Tomcat/webapps directory and NOT have Spring Context Loader load twice. What was your server.xml before you moved it? Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Mark, Here's the server.xml before moving abc out of the webapps directory: ?xml version='1.0' encoding='utf-8'? Server port=8005 shutdown=SHUTDOWN Listener className=org.apache.catalina.core.AprLifecycleListener SSLEngine=on / Listener className=org.apache.catalina.core.JasperListener / Listener className=org.apache.catalina.mbeans.ServerLifecycleListener / Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener / GlobalNamingResources Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / /GlobalNamingResources Service name=Catalina Connector port=8080 protocol=HTTP/1.1 connectionTimeout=2 redirectPort=8443 / Connector port=8443 protocol=HTTP/1.1 SSLEnabled=true maxThreads=150 scheme=https secure=true clientAuth=false sslProtocol=TLS / Connector port=8009 protocol=AJP/1.3 redirectPort=443 / Engine name=Catalina defaultHost=localhost Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host Host name=abc.local appBase=webapps/abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path= docBase= /Context /Host /Engine /Service /Server On Tue, May 4, 2010 at 10:53 AM, Mark Thomas ma...@apache.org wrote: On 04/05/2010 17:43, Joe Hansen wrote: Thank you for the super quick reply Mark! We are using Java Spring. The reason for moving the web application out of the webapps directory was that the Spring Context Loader was loading twice. First because its in the webapps directory. Secondly, because it is being referred to by the Host entry in the server.xml file. So how do I keep the web application out of Tomcat/webapps directory make the docBase different from the appBase? Or is there a way to keep the web application in the Tomcat/webapps directory and NOT have Spring Context Loader load twice. What was your server.xml before you moved it? Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
On 04/05/2010 17:59, Joe Hansen wrote: Mark, Here's the server.xml before moving abc out of the webapps directory: Host name=abc.local appBase=webapps/abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path= docBase= /Context /Host And therein lies the problem. docBase= is not valid. Currently, your app is deployed once under localhost with context path /abc and is partially deployed under abc.local with context path . Additionally, every directory under webapps/abc will be deployed as a web application under abc.local Quite a mess. What is it you are trying to achieve? Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Host name=localhost appBase=webapps /Host Host name=abc.local appBase=webapps/abc First problem: overlapping appBase settings for multiple Host elements. They must be distinct. Context path= docBase= /Context Second problem: a completely invalid Context setting, plus it's in server.xml, which is inappropriate. If you want a second Host (do you really need one?), and you want to specify a default webapp for it, create a separate directory for that Host's appBase, and place the desired webapp in ROOT (or ROOT.war) under that directory. Note that the name ROOT is case-sensitive, even on Windows. You do not need a Context element at all for this simple case. Should the webapp evolve to where it does need a Context, it should be placed in ROOT/META-INF/context.xml. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Thanks for the reply, Mark. You made me understand the mess I have created. I have written two web applications abc and xyz. I have mapped abc.local and xyz.local to my machine's IP Address in my Windows HOST file. So when I visit http://abc.local, I would want the abc web application to be accessed. When I visit http://xyz.local, I would want the xyz web application to be accessed. This is what I have been trying to achieve. Apparently I have been doing this the wrong way. Looks like I have some reading to do! Will post back after I read some Tomcat documentation. Thanks again! Joe On Tue, May 4, 2010 at 11:13 AM, Mark Thomas ma...@apache.org wrote: On 04/05/2010 17:59, Joe Hansen wrote: Mark, Here's the server.xml before moving abc out of the webapps directory: Host name=abc.local appBase=webapps/abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false Context path= docBase= /Context /Host And therein lies the problem. docBase= is not valid. Currently, your app is deployed once under localhost with context path /abc and is partially deployed under abc.local with context path . Additionally, every directory under webapps/abc will be deployed as a web application under abc.local Quite a mess. What is it you are trying to achieve? Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Looks like I have some reading to do! Will post back after I read some Tomcat documentation. Start here: http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Many Thanks for the link Chuck! Here's what I did. 1. Created a directory named c:\Tomcat\abc\ROOT. 2. Moved the previous contents of c:\Tomcat\webapps\abc to c:\Tomcat\abc\ROOT directory. 3. Created c:\Tomcat\abc\ROOT\META-INF\context.xml. Here's that file. ?xml version=1.0 encoding=UTF-8? Context ResourceLink global=jdbc/ProgressDatabase name=jdbc/ProgressDatabase type=javax.sql.DataSource / /Context 4. Changed c:\Tomcat\conf\server.xml to Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host Host name=abc.local appBase=abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host End Result is: 1. Spring Context loader is loaded only once (Great!). 2. But the web application logging is working wierdly.The log entries are written to c:\Tomcat\logs\xyz.log (i.e. the xyz web application's log) instead of writing to c:\Tomcat\logs\abc.log. . Here's the c:\Tomcat\abc\ROOT\WEB-INF\classes\log4j.properties file. log4j.rootLogger=INFO, A2 log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A2.File=c:/Tomcat6/logs/trestlewood.log log4j.appender.A2.MaxFileSize=100KB log4j.appender.A2.MaxBackupIndex=4 Please advise! Thank you! Joe On Tue, May 4, 2010 at 11:30 AM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Looks like I have some reading to do! Will post back after I read some Tomcat documentation. Start here: http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Joe Hansen wrote: Many Thanks for the link Chuck! Here's what I did. 1. Created a directory named c:\Tomcat\abc\ROOT. 2. Moved the previous contents of c:\Tomcat\webapps\abc to c:\Tomcat\abc\ROOT directory. ... Let me throw in my grain of salt. I like things organised in a logical way, with a structure that immediately makes it clear to anyone what one is trying to achieve. And I like to have things that are logically at the same level, to also look that way at the physical level if possible. Your mileage may vary as they say, but I would do as follows : The basic Tomcat, which as downloaded and installed from the one and only original and genuine site, is structured as follows : C:/tomcat : top installation dir (*) | --- bin : the programs --- conf : the configuration files --- lib : common things --- webapps : standard and example applications + maybe your applications | --- ROOT : the standard default application --- etc.. Nice, clear, clean, matches the documentation etc.. In your server.xml, there is a single Host defined, it answers to the name localhost, and it is also the default host, which means that if some DNS hostname evaluates to the IP address of your host computer, then any request addressed to that DNS hostname will be processed according to the setup of that Host. To indicate that the web applications for that host live under c:/tomcat/webapps, there is the appBase attribute of the Host tag : Host name=localhost appBase=webapps webapps being relative and thus interpreted as a subdirectory of the tomcat running directory, or CATALINA_BASE, which itself by default is the same as CATALINA_HOME, which is the tomcat installation directory c:/tomcat. Now you add two web applications abc and xyz. The normal place would be to install these under c:/tomcat/webapps/abc and c:/tomcat/webapps/xyz. But then, you would have to access them via URLs like http://hostname:port/abc http://hostname:port/xyz Instead, you would like to access them as respectively http://abc.local/ http://xyz.local That requires 2 parts : 1) you have to make abc.local and xyz.local into DNS aliases evaluating to the same IP address as your physical host. That, you did already, in part. 2) you have to make each of these applications be the default application, so that you can call them without the prefix (abc or xyz). That is a problem, because - there is already a ROOT application (the default Tomcat one) - abc and xyz cannot be both renamed to ROOT So you decide to solve this by using virtual hosts. Very good, that is one of the ways. So we add 2 virtual host declarations to the Tomcat server.xml, for a total of 3 : Host namelocalhost appBase=webapps ... Host nameabc.local appBase=webapps-abc ... Host name=xyz.local appBase=webapps-xyz and we change our basic directory layout to be : C:/tomcat : top installation dir | --- bin : the programs --- conf : the configuration files --- lib : common things --- webapps : standard and example applications + maybe some of your applications | --- ROOT : the standard default application --- webapps-abc : the applications of the abc.local host | |-- ROOT : the default application of the abc.local host --- webapps-xyz : the applications of the xyz.local host | |-- ROOT : the default application of the xyz.local host --- etc.. This way, you get to keep the standard and example applications of the original Tomcat, to test and play around with. These will be called whenever there is a request to http://localhost/ http://127.0.0.1/ http://anything/ as long as anything evaluates to one of the IP addresses of your physical host, and there is no specific Host name=anything defined. And whenever someone uses one of the names defined in a Host tag, they will be directed to the corresponding appBase applications. Also, the appBase's do not overlap, and they are at the same level in the file hierarchy, which is easy to understand, conveys well the idea that they are two choices at the same level, simplifies permission settings, is easy for backups etc.. There are other techniques and layouts possible to achieve the same effect, but I would not in any case base one application under tomcat_dir/abc and another one under tomcat_dir/webapps/xyz because I would find that confusing, and because I would not want the future Tomcat developers of version 9.3 to suddenly find that abc or xyz would be a cute name for a future indispensable Tomcat subdirectory to store whatever. I would also not want my boss to get the idea that the real nice name for application abc should really be server, and make things really messy. (*) In fact, it isn't. It normally wants to install itself in some awfully chosen directory with plenty of spaces in the name, guaranteed to give you stomac acidity some
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Joe, On 5/4/2010 1:26 PM, Joe Hansen wrote: I have written two web applications abc and xyz. I have mapped abc.local and xyz.local to my machine's IP Address in my Windows HOST file. So when I visit http://abc.local, I would want the abc web application to be accessed. When I visit http://xyz.local, I would want the xyz web application to be accessed. This is what I have been trying to achieve. Apparently I have been doing this the wrong way. Looks like I have some reading to do! Will post back after I read some Tomcat documentation. You want this: webapps/abc webapps/abc/ROOT -- this is your abc webapp webapps/abc/ROOT/META-INF webapps/abc/ROOT/META-INF/context.xml webapps/xyz webapps/xyz/ROOT -- this is your xyz webapp webapps/xyz/ROOT/META-INF webapps/xyz/ROOT/META-INF/context.xml It looks like you don't have any custom configuration for your Context, so you don't even need META-INF/context.xml files for either of your webapps. Set up two Hosts: Engine defaultHost=abc Host name=abc appBase=webapps/abc autoDeploy=true Aliasabc.local/Alias /Host Host name=xyz appBase=webapps/xyz autoDeploy=true Aliasxyz.local/Alias /Host /Engine Many administrators would expect that CATALINA_BASE/webapps is the auto-deployment directory for a standard setup, so maybe instead of the above paths, you'd want to move webapps/xyz and webapps/abc outside of CATALINA_BASE, and then refer to them appropriately from within server.xml. This should avoid double-deployment. Basically, these are the best-practices for Tomcat configuration: 1. Never declare Context elements in server.xml 2. Use the default auto-deploy Host and put your webapps into the appBase directory... remember to use ROOT as appropriately 3. If you don't want your webapps to be in the auto-deploy directory, then use conf/[Service]/[Engine]/[webappname].xml to configure your webapps instead. Good luck, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvgfKwACgkQ9CaO5/Lv0PBj4wCfaCKJ2cQUT7a9kC6rzdIVcho5 pGUAnioMCN5xtZD7bYPHV+5AdCRCKaX0 =6FLu -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Christopher Schultz [mailto:ch...@christopherschultz.net] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory You want this: webapps/abc webapps/abc/ROOT -- this is your abc webapp webapps/abc/ROOT/META-INF webapps/abc/ROOT/META-INF/context.xml webapps/xyz webapps/xyz/ROOT -- this is your xyz webapp webapps/xyz/ROOT/META-INF webapps/xyz/ROOT/META-INF/context.xml No, you don't want the above. That has overlapping appBase directories. As pointed out by both André and myself, keep them separate, at the same level of the directory hierarchy: webapps webapps/ROOT webapps/examples ... webapps-abc webapps-abc/ROOT -- this is your abc webapp webapps-abc/ROOT/META-INF webapps-abc/ROOT/META-INF/context.xml webapps-xyz webapps-xyz/ROOT -- this is your xyz webapp webapps-xyz/ROOT/META-INF webapps-xyz/ROOT/META-INF/context.xml The above will preserve your existing Tomcat webapps. Set up two Hosts: Engine defaultHost=abc Host name=abc appBase=webapps/abc autoDeploy=true Aliasabc.local/Alias /Host Host name=xyz appBase=webapps/xyz autoDeploy=true Aliasxyz.local/Alias /Host /Engine This destroys access to the Tomcat-supplied webapps, so don't do that. Add the two new Host elements, but don't replace the existing one, and don't change what defaultHost points to - unless you really, really want the replacement to be the default. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Thanks Andre and Chuck. Andre, I renamed Tomcat/abc/ to Tomcat/webapps-abc/ to keep the naming consistent. The directory structure that you've advocated is exactly the same as the one Chuck told me. And I have implemented that. However, logging is still an issue. One webapp's log4j seems to stomp over other webapp's log files. What could I be doing wrong? Here are the log4j configuration files: /* c:\Tomcat\webapps-abc\ROOT\WEB-INF\classes\log4j.properties */ log4j.rootLogger=INFO, A1 log4j.appender.A1=org.apache.log4j.RollingFileAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A1.File=c:/Tomcat/logs/abc.log log4j.appender.A1.MaxFileSize=100KB log4j.appender.A1.MaxBackupIndex=4 /* c:\Tomcat\webapps-xyz\ROOT\WEB-INF\classes\log4j.properties */ log4j.rootLogger=INFO, A2 log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A2.File=c:/Tomcat/logs/xyz.log log4j.appender.A2.MaxFileSize=100KB log4j.appender.A2.MaxBackupIndex=4 According to the following link, http://stackoverflow.com/questions/217929/problem-with-commons-logging-log4j-setup-in-spring-webapp-with-tomcat-6 If you have multiple webapps on the server, then you'll need discipline that each webapp's log initialization does not stomp on the initialization of other webapps. Each webapp will need to use unique Logger IDs, which can be accomplished with unique package names. Thank you! Joe - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chuck, On 5/4/2010 4:08 PM, Caldarale, Charles R wrote: From: Christopher Schultz [mailto:ch...@christopherschultz.net] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory You want this: webapps/abc webapps/abc/ROOT -- this is your abc webapp webapps/abc/ROOT/META-INF webapps/abc/ROOT/META-INF/context.xml webapps/xyz webapps/xyz/ROOT -- this is your xyz webapp webapps/xyz/ROOT/META-INF webapps/xyz/ROOT/META-INF/context.xml No, you don't want the above. That has overlapping appBase directories. FWIW, it doesn't (given my proposed server.xml). As pointed out by both André and myself, keep them separate, at the same level of the directory hierarchy: I did note that this would be a good idea, since most people expect CATALINA_BASE/webapps to be the auto-deployment directory and seeing subdirs would be confusing at least. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvgihwACgkQ9CaO5/Lv0PBMgQCggnmxr8NRL/fe0Zo5ibYxZ4/U 8l0AnRAD7nMj4MbsC5NNEJOnsZK8j8Vp =DuXA -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
On 04/05/2010 18:59, Joe Hansen wrote: Many Thanks for the link Chuck! Here's what I did. 1. Created a directory named c:\Tomcat\abc\ROOT. 2. Moved the previous contents of c:\Tomcat\webapps\abc to c:\Tomcat\abc\ROOT directory. 3. Created c:\Tomcat\abc\ROOT\META-INF\context.xml. Here's that file. ?xml version=1.0 encoding=UTF-8? Context ResourceLink global=jdbc/ProgressDatabase name=jdbc/ProgressDatabase type=javax.sql.DataSource / /Context 4. Changed c:\Tomcat\conf\server.xml to Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host Host name=abc.local appBase=abc unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false /Host End Result is: 1. Spring Context loader is loaded only once (Great!). 2. But the web application logging is working wierdly.The log entries are written to c:\Tomcat\logs\xyz.log (i.e. the xyz web application's log) instead of writing to c:\Tomcat\logs\abc.log. . Here's the c:\Tomcat\abc\ROOT\WEB-INF\classes\log4j.properties file. log4j.rootLogger=INFO, A2 log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A2.File=c:/Tomcat6/logs/trestlewood.log log4j.appender.A2.MaxFileSize=100KB log4j.appender.A2.MaxBackupIndex=4 And what about the xyz one? p Please advise! Thank you! Joe On Tue, May 4, 2010 at 11:30 AM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Looks like I have some reading to do! Will post back after I read some Tomcat documentation. Start here: http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org signature.asc Description: OpenPGP digital signature
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory However, logging is still an issue. One webapp's log4j seems to stomp over other webapp's log files. What could I be doing wrong? Where is your log4j.jar located? You should have one copy in each webapp's WEB-INF/lib directory. If you've placed log4j.jar in a common location, I think it will use the properties of the first webapp that references it for all the webapps. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Chuck, Initially I placed log4j-1.2.15.jar in the c:\Tomcat\lib directory only. This resulted in abc webapp logging in the c:\Tomcat\logs\xyz.log file. When I copied the log4j-1.2.15.jar to c:\Tomcat\webapps-abc\ROOT\WEB-INF\lib and c:\Tomcat\webapps-xyz\ROOT\WEB-INF\lib directories, it created empty abc.log and xyz.log files. When I delete c:\Tomcat\lib\log4j-1.2.15.jar, I get Tomcat startup errors (NoClassDefFoundError: org/apache/log4j/Category). Also empty abc.log and xyz.log files are created. Joe On Tue, May 4, 2010 at 3:20 PM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory However, logging is still an issue. One webapp's log4j seems to stomp over other webapp's log files. What could I be doing wrong? Where is your log4j.jar located? You should have one copy in each webapp's WEB-INF/lib directory. If you've placed log4j.jar in a common location, I think it will use the properties of the first webapp that references it for all the webapps. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Initially I placed log4j-1.2.15.jar in the c:\Tomcat\lib directory only. This resulted in abc webapp logging in the c:\Tomcat\logs\xyz.log file. As expected - first one in wins. When I copied the log4j-1.2.15.jar to c:\Tomcat\webapps-abc\ROOT\WEB-INF\lib and c:\Tomcat\webapps-xyz\ROOT\WEB-INF\lib directories, it created empty abc.log and xyz.log files. That's a least a good start - the separate appenders created the desired files. One presumes you expected the files to actually have something in them... When I delete c:\Tomcat\lib\log4j-1.2.15.jar, I get Tomcat startup errors (NoClassDefFoundError: org/apache/log4j/Category). Let's see the complete stack trace for that error. Do you have other classes in Tomcat's lib directory that are shared by the webapps, and do those classes attempt to do logging? Unless you really need them to be shared, put those classes in each webapp's WEB-INF/lib or WEB-INF/classes directories. Otherwise, you'll need to modify your code and have each webapp pass in or otherwise expose its logger to the methods of the common classes. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Chuck, There are common classes in Tomcat/lib/ but they don't attempt to do any logging. However, the abc Spring Web application does initialize a Quartz object which runs once every hour and does some logging. I don't know if that has any implications. Thanks, Joe Here's the stack trace from catalina.log file... INFO: Initializing log4j from [C:\Tomcat6\webapps-abc\ROOT\WEB-INF\classes\log4j.properties] May 4, 2010 4:06:53 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.ExceptionInInitializerError at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:53) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:44) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:583) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@20f443 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@20f443 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351) at org.springframework.web.context.ContextLoader.clinit(ContextLoader.java:146) ... 26 more Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@20f443 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529) ... 30 more Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getConstructor(Unknown Source) at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410) ... 31 more Here's the stack trace from localhost.log file... INFO: Initializing log4j from [C:\Tomcat6\webapps-xyz\ROOT\WEB-INF\classes\log4j.properties] May 4, 2010 4:06:54 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Joe, On 5/4/2010 1:59 PM, Joe Hansen wrote: 2. But the web application logging is working wierdly.The log entries are written to c:\Tomcat\logs\xyz.log (i.e. the xyz web application's log) instead of writing to c:\Tomcat\logs\abc.log. . Here's the c:\Tomcat\abc\ROOT\WEB-INF\classes\log4j.properties file. Oh, I forgot to mention in my other message: you should put log4j.log into your webapp's WEB-INF/lib directory and not share it between webapps. Several reasons: 1. log4j can only be initialized in one way. You can re-initialize, but that's not what you want. 2. Webapps ought to be self-contained, other than the APIs guaranteed to be provided by the container. 3. Your webapp A might need a different version of log4j (or any other library for that matter), and therefore they just can't share. It's just a better idea to bundle the required libraries with your webapp. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvgfVAACgkQ9CaO5/Lv0PDG/ACeMCgC8sgx6u9do6yASUGESN25 tecAn3MwvXH7cqB75S6yUnSJfbv1GBaE =ud2n -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Joe, On 5/4/2010 6:15 PM, Joe Hansen wrote: There are common classes in Tomcat/lib/ but they don't attempt to do any logging. Are you sure? However, the abc Spring Web application does initialize a Quartz object which runs once every hour and does some logging. I don't know if that has any implications. It appears so: Here's the stack trace from catalina.log file... INFO: Initializing log4j from [C:\Tomcat6\webapps-abc\ROOT\WEB-INF\classes\log4j.properties] May 4, 2010 4:06:53 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.ExceptionInInitializerError at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:53) [...] java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@20f443 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)) Looks like you've got a common logging framework configured to use log4j. If you use Spring and they use commons-logging, you need to: 1. Move spring.jar into WEB-INF/lib 2. Move commons-logging.jar into WEB-INF/lib Basically, move everything your webapp needs into WEB-INF/lib. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvgnYYACgkQ9CaO5/Lv0PBeXwCfYQwTWJBVUg+fri9Wbz0/S/Tk GI8An2kzGimP4qwxgLaqLPva5qYxe/hg =mWKe -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Thanks for the reply, Charles! When commons-logging.jar is present in Tomcat/lib and WEB-INF/lib directories, I get the following error : Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. Here's the complete stack trace: 2010 May 04 / 16:28:34 ERROR - [org.springframework.web.context.ContextLoader] : Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in ServletContext resource [/WEB-INF/abc-jdbc.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.quartz.impl.StdSchedulerFactory]: Constructor threw exception; nested exception is org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.)) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630) at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:722) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Christopher Schultz [mailto:ch...@christopherschultz.net] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Oh, I forgot to mention in my other message: you should put log4j.log into your webapp's WEB-INF/lib directory Presumably, you mean log4j.jar, not log4j.log - which we already told him to move. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory When commons-logging.jar is present in Tomcat/lib and WEB-INF/lib directories, I get the following error : As you should. As Chris said, put everything (including the spring jars) in each webapp's WEB-INF/lib directory, and as little as possible (preferably nothing) in Tomcat's lib directory. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Chuck, please note that when commons-logging.jar is present only in the WEB-INF/lib directory, I get the following error: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory So, either I get a) Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. or b) java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory I am really stumped. I even tried the following: Context loader delegate=“false”/ /Context which the following link recommends. http://www.richardrauser.com/index.php/2009/09/02/log4j-multiple-web-apps-common-lib-logging/ But that doesn't solve my issue. Thanks, Joe On Tue, May 4, 2010 at 4:58 PM, Caldarale, Charles R chuck.caldar...@unisys.com wrote: From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory When commons-logging.jar is present in Tomcat/lib and WEB-INF/lib directories, I get the following error : As you should. As Chris said, put everything (including the spring jars) in each webapp's WEB-INF/lib directory, and as little as possible (preferably nothing) in Tomcat's lib directory. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Joe Hansen wrote: Chuck, please note that when commons-logging.jar is present only in the WEB-INF/lib directory, I get the following error: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory So, either I get a) Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. or b) java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory Really adventuring into areas unknown to me here, but might there not by any chance be /another/ webapp, in which you did /not/ in that case give its own copy of the jar of its own ? (like under server/webapps ?) - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
This thread has grown too long. For anyone following this thread, here's the summary: Two web applications, each with a Virtual Host entry in server.xml file. Tomcat/webapps-abc Tomcat/webapps-xyz These two web applications have different log4j.properties files. These log4j property files log to different log files (Tomcat/logs/abc.log and Tomcat/logs/xyz.log). Tomcat/webapps-abc/ROOT/WEB-INF/classes/log4j.properties Tomcat/webapps-xyz/ROOT/WEB-INF/classes/log4j.properties The web applications abc and xyz using Java Commons Logging API (Log and LogFactory classes) to perform logging. Scenario 1: log4j.jar is in Tomcat/lib directory log4j.jar is NOT in WEB-INF/lib directories Result: abc webapp's log entries are written to xyz.log file Scenario 2: log4j.jar is NOT in Tomcat/lib directory log4j.jar is in WEB-INF/lib directories Result: ClassNotFoundError in Tomcat/logs/catalina.log files Scenario 3: log4j.jar is in Tomcat/lib directory log4j.jar is in WEB-INF/lib directories Result: Empty abc.log and xyz.log files. Here's the relevant portion of the webapps-abc/ROOT/WEB-INF/web.xml file: listener listener-classorg.springframework.web.util.Log4jConfigListener/listener-class /listener context-param param-namelog4jConfigLocation/param-name param-value/WEB-INF/classes/log4j.properties/param-value /context-param context-param param-namelog4jExposeWebAppRoot/param-name param-valuefalse/param-value /context-param listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener webapps-xyz/ROOT/WEB-INF/web.xml file looks just the same /* webapps-abc/ROOT/WEB-INF/classes/log4j.properties */ log4j.rootLogger=INFO, A2 log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A2.File=c:/Tomcat6/logs/abc.log log4j.appender.A2.MaxFileSize=100KB log4j.appender.A2.MaxBackupIndex=4 /* webapps-xyz/ROOT/WEB-INF/classes/log4j.properties */ log4j.rootLogger=INFO, A1 log4j.appender.A1=org.apache.log4j.RollingFileAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d{ MMM dd / HH:mm:ss} %-5p - [%c] : %m %n log4j.appender.A1.File=c:/Tomcat6/logs/xyz.log log4j.appender.A1.MaxFileSize=100KB log4j.appender.A1.MaxBackupIndex=4 - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
From: Joe Hansen [mailto:joe.hansen...@gmail.com] Subject: Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory Scenario 1: log4j.jar is in Tomcat/lib directory log4j.jar is NOT in WEB-INF/lib directories Have you added *anything* else to Tomcat's lib directory? Scenario 3: log4j.jar is in Tomcat/lib directory log4j.jar is in WEB-INF/lib directories You must never have the same classes located in more than one spot in a given branch of the classloader tree, so the above is not a valid configuration. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org