The org.eclipse.wst.common.component file generated by Gradle’s EclipseWtp plugin is subtly different from the equivalent file when creating a project in Eclipse or when using Maven’s eclipse plugin i.e. the ‘wb-resource’'s ‘source-path’ value does not start with a forward slash.
This causes errors when deploying to WebSphere Liberty Profile (WLP) in Eclipse if WLP is setup to use loose configuration.
I’m willing to implement or help with a fix if this is considered a bug but I first want to hear what you guys are saying.
- Build a multi-project webapp with Gradle 2. Import project into Eclipse using Gradle EclipseWtp plugin 3. Deploy to WebSphere Liberty Profile (WLP) from Eclipse using loose config i.e. with “Run applications directly from the workplace” enabled.
Problem Symptom: When deploying to WLP in Eclipse (with “Run applications directly from the workspace” enabled) the server cannot find the servlet:
Error 404: javax.servlet.UnavailableException: SRVE0200E: Servlet [pack.MyServlet]: Could not find required class - pack/MyServlet
If the project is deployed as a packaged WAR this error does not occur. Tomcat (or more specifically vFabric tc Server) can deploy the same project even with their “Serve modules without publishing” enabled.
Cause of Problem:
1. Gradle doesn’t generate a org.eclipse.wst.common.component file that is consistent with Eclipse generated or Maven generated metadata.
I.e. the source-path does not start with a leading slash.
<wb-resource deploy-path="/WEB-INF/classes" source-path="src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
2. WebSphere Liberty Profile server is not tolerant enough since Tomcat can deploy the app with loose config?
I created a minimal webapp to illustrate the problem. Even though this is a single-project webapp the same problem would exist in the dependencies. Build instructions can be found in the README
Gradle makes it difficult/hackish to work around this problem.
For the web project you could use the ‘eclipse.wtp.component.whenMerged’ hook to edit the file.
However in a multi-project build you cannot do that for the dependencies since the wtp config is not available for non-war/non-ear projects.
A comment on one of the tickets recommends the following: 1. Apply the War or Ear plugin 2. Manually add and configure a GenerateEclipseWtpFacet task
Does anyone know if there is a spec for the org.eclipse.wst.common.component file?