This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes maven log4j problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven log4j problem" Watch "maven log4j problem" New topic
Author

maven log4j problem

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

hello,
i use maven log4j depency below to integrate log4j into my project


i use Log4j in a servlet ,but when i run servlet on tomcat 7 i get this error below.
why does my servlet throw this error eventhough i included log4j dependency in my pom.xml file?
I'm new to maven so maybe i'm doing something wrong. thanks for helping on this!

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

Yahya Elyasse wrote:... i use Log4j in a servlet ,but when i run servlet on tomcat 7 i get this error below...

What's inside your application in Tomcat, Is the required jar (log4j) file in the lib directory?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Radovan Vukovic
Greenhorn

Joined: Nov 03, 2010
Posts: 19
Try to set scope at your log4j dependency.
If log4j is included in Tomcat lib directory set scope to provided
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Welcome to Javaranch Radovan Vukovic!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Vijitha Kumara wrote:
Yahya Elyasse wrote:... i use Log4j in a servlet ,but when i run servlet on tomcat 7 i get this error below...

What's inside your application in Tomcat, Is the required jar (log4j) file in the lib directory?


No i removed the log4j.jar file from WEB-INF /lib/ directory. since i use maven log4j then i don't need to have the jar in web-inf/lib ? that's why we use maven anyway! to get rid of all those jars in lib directory. however this doesn't work for my servlet and i don't know why.

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

Yahya Elyasse wrote:...No i removed the log4j.jar file from WEB-INF /lib/ directory. since i use maven log4j then i don't need to have the jar in web-inf/lib ? that's why we use maven anyway! to get rid of all those jars in lib directory...

You need the required jars in the runtime environment whether those are downloaded by Maven as a part of the project build. I'll ask it again, do you have those inside the final product (WAR file or ....), which is what being deployed to the server?
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Vijitha Kumara wrote:
Yahya Elyasse wrote:...No i removed the log4j.jar file from WEB-INF /lib/ directory. since i use maven log4j then i don't need to have the jar in web-inf/lib ? that's why we use maven anyway! to get rid of all those jars in lib directory...

You need the required jars in the runtime environment whether those are downloaded by Maven as a part of the project build. I'll ask it again, do you have those inside the final product (WAR file or ....), which is what being deployed to the server?


no probably the war doesn't contains it. in fact i run the servlet from eclipse IDE on a tomcat 7 server instance that i added to my web project via eclipse. so i guess eclipse doesn't include the log4j.jar when deploying servlet into tomcat. the question : is there a way to instruct eclipse to copy the maven dependencies libraries intoin the web-inf/lib when running web app inside tomcat?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

If the project is built by Eclipse (that is with no other tool like Ant) then the required files should be placed where Eclipse expect them to be (this may depends on the type of project you are using dynamic web project etc....).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: maven log4j problem
 
Similar Threads
How to get Maven to include "persistence.xml" into a web app??
Error deploying Axis2 web service created by Maven
java.lang.NoClassDefFoundError: oracle/toplink/essentials/ejb/cmp3/EntityManagerFactoryProvider
Error deploying Axis2 web service created by Maven
java.lang.ClassCastException: org.apache.tiles.jsp.taglib.InsertAttributeTag cannot be cast to javax