This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

maven log4j problem

 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Radovan Vukovic
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to set scope at your log4j dependency.
If log4j is included in Tomcat lib directory set scope to provided
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch Radovan Vukovic!
 
Yahya Elyasse
Ranch Hand
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 510
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic