문제

Using Eclipse 4.2 I am trying to deploy a web application that consists in a main Dynamic Web project and a Web Fragment project.

The Web Fragment needs some jar libraries (lib1.jar and lib2.jar) that are not needed at compile time by the main project. To add these libraries I have two options:

  1. Put them in the Java Build Path each one has a single entry
  2. Put them in a WEB-INF/lib folder under the src folder and add a "Web App Libraries" library to the Java Build Path

In both case I mark the libraries as exported in the "Order and Export" tab of the Java Build Path

When I publish the corresponding server that uses Tomcat 7.0.041 or export the war I end with the follwing scenarios:

  1. In case 1 no library (lib1.jar neither lib2.jar) is copied to the main WEB-INF/lib folder
  2. In case 2 both libraries are copied inside the WEB-INF/lib folder of the web fragment generated jar file which in turn is copied to the main WEB-INF/lib folder.

When starting the server a ClassNotFoundException is thrown in both scenarios for classes residing in lib1.jar or lib2.jar.

Is there any way to deploy the libs needed for the Web Fragment project without putting them manually in the main project?

도움이 되었습니까?

해결책

I have just found a two step answer to my question.

In the scenario #1 above after doing it you have to go the Web Fragment project properties and then go to Deployment Assembly, press the "Add" button, select Java Build Path Entries and select all the libraries you want to be included in the WEB-INF/lib directory of the server.

Once this is done the libraries selected will be copied to the WEB-INF/lib when publishing the server or exporting the war.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top