3.6: External Jars in a Dynamic Web Project [message #544731] |
Mon, 05 July 2010 11:45 |
Rusi Filipov Messages: 2 Registered: July 2010 |
Junior Member |
|
|
What is the right way to use external libraries from within a Dynamic Web Project?
I have a super-clean minimal setup:
* new Eclipse WTP 3.6 64-bit, official distribution, no other plugins
* new workspace
* new Tomcat 6.26, only unpacked, no other modifications
* new Server Runtime, no modifications, default settings
* new Dynamic Web Project, default settings
* new JSP page saying "hello"
* Add to Server, Run
Until here it works fine!
Now I want to use Log4j:
* Build Path > Add External JARs...
* Browse and select the Log4j Library
* new Servlet, default settings
* print a logging statement in doGet()
* restart the server
* open the Servlet URL in the Browser
ClassNotFoundException: org.apache.log4j.Logger
The project is published, but WEB-INF/lib is empty.
Then I found the "Deployment Assembly" page under Project Properties.
* Add.. > External Archive
* Browse and select the Log4j Library
* Restart Server
Now it works. WEB-INF/lib contains log4j.jar.
Nothing else in "Deployment Assembly" works.
Configuring the external libraries in both the Build Path and Deployment Assembly seems so redundant. Is this the right way to use external libraries?
This took me 2 days of trial/error with every setting imaginable. It is part of an effort to get a Maven Project deployable with WTP.
|
|
|
Re: 3.6: External Jars in a Dynamic Web Project [message #544815 is a reply to message #544731] |
Mon, 05 July 2010 15:11 |
|
Have to agree with that.
Though in your case you could have created a "User Library" just to avoid adding every jar manually at the "Deployment Assembly". Not that it would make any difference in terms of having to define it in 2 different places.
It's more of a pain really when you have a maven enabled project like you mention as adding the referenced maven dependencies doesn't seem to work.
Quote: | I have tried adding maven either as a "Classpath Container" or as "Referenced Projects Classpath Entries" but neither of them seem to work.
Then first option just comes up with a message that points you to the Maven properties to setup the dependencies while the second one although added (even with the correct "Deploy Path" set to "/WEB-INF/lib") doesn't seem to copy the required libs.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03468 seconds