Transit Dependent Projects in Eclipse WTP

I created a bunch of projects in Eclipse 3.7.2. Let some of them be called:

  • W (dynamic web project)
  • A (some library)
  • B (a library with many common things that is also used by other projects)

Project A depends on project B, so B is on the build path of A. Project W depends on project A, so I added A as a deployment build in W.

When I export a WAR from Eclipse, only the JAR file for A is added to WEB-INF / lib. Eclipse shows the following warning:

The pathpath / B element will not be exported or published. runtime This can lead to the appearance of ClassNotFoundExceptions.

The warning is true. I get ClassNotFoundExceptions at runtime. Of course, Eclipse provides a quick fix for the warning, which is “Mark the associated source class path entry as a publish / export dependency”. However, this does not fix my problem. B still does not deploy with W.

I tried manually adding B as a deployment assembly in A. This includes B.jar in A.jar, which is not what I want, and I still get ClassNotFoundExceptions.

The only thing that works is to manually add B as the deployment assembly in W. Eclipse still shows a warning from above, but there is no runtime exception.

Am I missing something or is this really the only way to get this to work?

+4
source share
1 answer

To make Eclipse "Export / Web / WAR File", you must make your project "b" to display the "Web Application Libraries" container.

You can change the deployment configuration using the deployment build page in the project properties and add your project "b" there:

deployment assembly

Alternatively, you can open the configuration file in /w/.settings/org.eclipse.wst.common.component and add the link to project "b" manually:

 <?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="w"> <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/> <dependent-module archiveName="a.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/a/a"> <dependency-type>uses</dependency-type> </dependent-module> <dependent-module archiveName="b.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/b/b"> <dependency-type>uses</dependency-type> </dependent-module> <property name="context-root" value="w"/> <property name="java-output-path" value="/w/build/classes"/> </wb-module> </project-modules> 

Once this is done, you will see project "b" in the class container of the Web Application Library, and exporting to the WAR file will also add b.jar to WEB-INF / lib.

+4
source

Source: https://habr.com/ru/post/1413841/


All Articles