Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse WTP, maven and m2eclipse - not copying provided jars

When using Eclipse WTP and m2eclipse it is possible to copy all dependencies to WEB-INF/lib (by adding "maven dependencies" in the Deployment assembly). However, dependencies with scope "provided" are also copied, for example el-api and jsp-api. That disturbs the container and it fails to start.

Any solution for not copying the "provided" jars?

like image 622
Bozho Avatar asked Aug 08 '11 08:08

Bozho


3 Answers

You have to install the m2eclipse-wtp which is an extra plug-in for m2eclipse .It will do this job for you. After installing the m2eclipse-wtp , just right-click project ---> Maven --> Update Project Configuration , you will find that the libs of the provided scope will not be distrusted to the WTP container anymore.

See this for the installation instruction. I would suggest to install the latest version of m2eclipse-wtp (tested against Eclipse 3.6 +) as it solves some major bugs in the previous versions.

Edit: Thanks Fred for the correction

like image 92
Ken Chan Avatar answered Nov 18 '22 19:11

Ken Chan


You need to add the Maven Library to WTP's Deployment Assembly...

Right click on your project, select "Properties"

From the properties menu click "Deployment Assembly"

Click "Add" -> "Java Build Path Entries" then click "Next"

Select "Maven Libraries" on the list and click "Finish"

like image 35
Mouscellaneous Avatar answered Nov 18 '22 20:11

Mouscellaneous


Dependencies of scope "provided" shouldn't be packaged by Maven in the final assembly.

However, check if you have other dependencies that are "compile" that also declare those same dependencies as "compile". In other words, it's very likely that el-api and jsp-api are being pulled in as transitive dependencies.

Easiest way to check is using the Dependency Hierarchy view of m2eclipse.

like image 1
Alistair A. Israel Avatar answered Nov 18 '22 18:11

Alistair A. Israel