Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some necessary libraries are missing in WAR-File after export from Eclipse - why?

I took over a project of a college which contains some web services and by exporting the project as WAR-file some libraries are contained in the file (e.g. Axis2) and some aren’t (hibernate, JDBC driver). Also a jar which is added to the class path has not been exported. All libraries are located in folders on the hard drive which means that they are not in located somewhere in the eclipse folder. If I open the WAR-file after export with WinRAR and add the libraries manually to the file the web service will work well but that is not a good solution… What could be the reason for that problem? And how can I solve it?

like image 693
Stephan Avatar asked Aug 20 '10 09:08

Stephan


People also ask

Does war file contain all dependencies?

Unlike a jar, a war file has a WEB-INF/lib directory which contains all of the dependency jars. So the war file has everything you need to start the webapp.

Where does eclipse put the war file?

Eclipse does not put anything anywhere itself. When you build the project using maven, according to maven folder structure it will build and put the war file in its target directory where the project is present in file system (mostly inside your workspace), which you can see on your eclipse package/project explorer.

What does a war file contain?

Each WAR file contains servlets, JSPs, a deployment descriptor, and related resource files. Static HTML files and JSP are stored at the top level of the WAR directory. The top-level directory contains the WEB-INF subdirectory which contains tag library descriptor files in addition to the following: Server-side classes.


1 Answers

The jar dependencies for Eclipse to include in a war file not placed in WEB-INF/lib is not managed by the usual "project export/imports" but by a separate panel (3.6: Deployment Assembly, 3.5: Java EE Module Dependencies) in the preferences of the dynamic web project.

alt text

Note: Since the answer was originally written, Maven has become the defacto packaging tool. Instead of relying on Eclipse features, I would strongly recommend to use Maven packaging instead. It has the additional benefit of making the project instantly usable with all modern IDE's.

like image 184
Thorbjørn Ravn Andersen Avatar answered Oct 19 '22 23:10

Thorbjørn Ravn Andersen