commons-logging classloader pain
I recently learned about commons-logging's classloader behavior the hard way when moving applications that use log4j from Tomcat to WebLogic. I had naively put commons-logging.jar in my WebLogic system classpath to emulate Tomcat's behavior, and things subsequently broke. This web site provided a very detailed and erudite explanation:
http://www.qos.ch/logging/classloader.jsp
Basically, it boils down to weird subtlety in commons-logging's behavior. If commons-logging.jar is in the system classpath in a J2EE environment, the "current" or "thread context" classloader for each individual webapp contains WEB-INF/lib, but commons-logging itself is loaded in the system (parent) classpath. commons-logging looks for log4j using the thread-context classloader and therefore will "see" log4j in WEB-INF/lib, but tries to actually load it in the system classpath, and breaks with a NoClassDefFoundError.
Various solutions:
- Only put commons-logging-api.jar in the system classpath, as Tomcat does. (I didn't realize there were two different variations of the JAR at first. I know, RTFM.) This stripped-down commons-logging will pretend that log4j doesn't exist. Downside: logging output from third-party APIs like Hibernate, Digester, etc. will go who-knows-where, but not the same place as your application's log4j output.
- Put log4j in the system classpath too. This works, but has the bad side effect that all applications will share a single log4j configuration and this makes logging unmanageable.
- Put commons-logging.jar in your WEB-INF/lib directory. I'd heard bad things about this, especially if you want to deploy the same WAR in Tomcat. But for whatever reason it worked fine with Tomcat 4.1.31 and WebLogic 8.1. So this may be my preferred solution.
Anyhow, if this was confusing to someone who has been doing J2EE professionally for 5-6 years, I can imagine how confusing it must be to someone just trying to do this for the first time. The BileBlog puts it a lot less charitably.

3 Comments:
Catch the wow gold star that holds your gold in wow destiny,cheap wow gold the one that forever maplestory money twinkles within your heart. Take advantage of precious opportunities while they still sparkle before you. Always believe that your buy maplestory mesos ultimate goal is attainable cheap mesos as long as you commit yourself to it.maple money Though barriers may sometimes stand in the way of your dreams, remember that your destiny is hiding behind them.wow gold kaufen Accept the fact that not everyone is going to approve of the choices Maple Story Accounts you've made. Have faith in your judgment.wow gold farmen Catch the star that maple story money twinkles in your heart and it will lead you to your destiny's path. Follow that pathway and uncover the sweet sunrises that await you. Take pride in your accomplishments, as they are stepping stones to your dreams. Understand that you may make mistakes, powerlevelbut don't let them discourage you.ms mesos Value your capabilities and talents for they are what make you truly unique. The greatest gifts in life are not purchased, but acquired through hard work and determination.maplestory mesos Find the star that twinkles in your heart?for you alone maplestory powerleveling are capable of making your brightest dreams come true. Give your hopes everything you've got and you will catch the star that holds your destiny.
By
uiyui, at 9:17 PM
放鬆心情自由自在的來一趟花蓮旅遊,可以感受花蓮民宿各種不同的風味,所以來花蓮一定要住花蓮民宿哦!因為可從花蓮民宿主人那裡分享到不一樣的花蓮旅遊經驗及花蓮美食道地的花蓮小吃,所以來花蓮旅遊不一定就要享受花蓮高級餐廳的花蓮美食也可以多試試道地古早味的花蓮美味哦!來花蓮民宿可以放鬆整個心情,來花蓮住宿也可以放空自已,來花蓮也可以了解在地的文化哦!住民宿其實是很輕鬆的,住花蓮民宿其實是很容易,還有就是現在是高油價的時代,還自行開車來花蓮嗎?來花蓮租車會比較輕鬆哦!來花蓮房屋租車會比較省錢哦!或是可以請花蓮計程車帶您包車旅遊喔!!歡迎來住住美麗的花蓮民宿囉!!一定要讓您來花蓮旅遊並且讓您愛上花蓮民宿,還有團購美食好吃的蜂蜜蛋糕
By
Anonymous, at 12:17 PM
酒店打工
酒店兼職
台北酒店
打工兼差
酒店工作
酒店經紀
禮服店
酒店兼差
酒店上班
酒店PT
酒店
By
Anonymous, at 8:13 PM
Post a Comment
<< Home