Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » 3.6: External Jars in a Dynamic Web Project(Jar does not get published - ClassNotFoundException)
3.6: External Jars in a Dynamic Web Project [message #544731] Mon, 05 July 2010 11:45 Go to next message
Rusi Filipov is currently offline 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 Go to previous messageGo to next message
Markos Charatzas is currently offline Markos Charatzas
Messages: 2
Registered: July 2009
Location: Edinburgh
Junior Member

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.

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.

Re: 3.6: External Jars in a Dynamic Web Project [message #544821 is a reply to message #544815] Mon, 05 July 2010 15:45 Go to previous message
Rusi Filipov is currently offline Rusi Filipov
Messages: 2
Registered: July 2010
Junior Member
My goal is to avoid maintaining dependency information anywhere else than in the Maven pom.xml. Our dependency graph includes directly 40+ and transitively 110+ dependencies and changes in dependencies or versions would require precise housekeeping of the User Library.

So far I found this partial solution. It works when used with Maven and the m2eclipse plugin:

0) clean everything that is Eclipse-related - delete .project .classpath .settings .externalToolBuilders. Eclipse will not recognize this as a project now.

1) In the terminal run
mvn -Dwtpversion=2.0 eclipse:eclipse

This will generate the Eclipse configuration and make it a Dynamic Web Project. The generated files will not be up to date with the current but WTP 3.2 which is integrated in Eclipse 3.6, but Eclipse/WTP will understand it. This will also populate the list in the Deployment Assembly page in Project Properties.

2) Refresh the project in Eclipse. It should be recognized as a Dynamic Web Project now.

3) Maven > Enable Dependency Management
This will enable the m2eclipse plugin and recognize it as a Maven Project.

When some dependency or version of dependency changes, you have to repeat from 1) to 3).

Previous Topic:Entity bean genertation for ejb3.0
Next Topic:JSF 2.0 completion in .xhtml files with Eclipse 3.6 M6
Goto Forum:

Current Time: Fri Oct 31 18:08:36 GMT 2014

Powered by FUDForum. Page generated in 0.01819 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software