Like others have already mentioned, this error seems to be coming back in Gradle-projects using the WAR plugin over and over again when the project is refreshed by Gradle or even otherwise, simply because it has been changed outside of Eclipse. While validating the project in Eclipse works, this is only a temporary workaround until the next refresh of the project. I've already cleaned every caches I could find and stuff, so doubt this has anything to with those.
Looking at the view for errors in Eclipse, there's an additional stacktrace available making things a bit clearer:
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException: WEB-INF/web.xml
Stack trace of nested exception:
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.EmptyResourceException: platform:/resource/de.am_soft.sm_mtg.frontend/WEB-INF/web.xml
at org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil.getRoot(ArchiveUtil.java:442)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.XmlBasedImportStrategyImpl.primLoadDeploymentDescriptor(XmlBasedImportStrategyImpl.java:42)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.War22ImportStrategyImpl.loadDeploymentDescriptor(War22ImportStrategyImpl.java:90)
at org.eclipse.jst.j2ee.commonarchivecore.internal.strategy.War22ImportStrategyImpl.importMetaData(War22ImportStrategyImpl.java:84)
at org.eclipse.jst.j2ee.commonarchivecore.internal.impl.WARFileImpl.getDeploymentDescriptor(WARFileImpl.java:146)
at org.eclipse.jst.j2ee.model.internal.validation.WarValidator.validateInJob(WarValidator.java:334)
at org.eclipse.jst.j2ee.internal.web.validation.UIWarValidator.validateInJob(UIWarValidator.java:113)
at org.eclipse.wst.validation.internal.operations.ValidatorJob.run(ValidatorJob.java:78)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
platform:/resource
is documented like the following by Eclipse:
It is used to identify a resource located in the workspace. The next path segment after "resource" should be the name of a project, which can be followed by the folder and/or file we want to locate.
So for some reason the validator expects WEB-INF/web.xml
being available in the root of the Eclipse-project, which doesn't make much sense to me: It has never been there in the past and putting it there doesn't resolve the error as well. Instead, Eclipse logs 20 new errors without any additional messages or stacktraces and I can't get rid of those anymore even after deleting WEB-INF/web.xml
, therefore restoring the former project state.
Similar errors have been reported for Eclipse projects in their bugtracker.
!ENTRY org.eclipse.wst.validation 4 0 2007-08-28 12:00:39.515
!MESSAGE
*** ERROR ***: Tue Aug 28 12:00:39 EDT 2007 org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException: WEB-INF/web.xml
Stack trace of nested exception:
org.eclipse.jst.j2ee.commonarchivecore.internal.exception.EmptyResourceException: platform:/resource/ARBankLogWeb/WebContent/WEB-INF/web.xml
My project was migrated from native Eclipse to Gradle with the WAR-plugin and the latter allows manually defining web.xml
. So I tried that, but didn't change a thing as well:
war
{
webXml = file('src/main/webapp/WEB-INF/web.xml')
}
So whatever the problem with the validator is for some project setups, the only workaround I could find reliably working currently is disabling it per project:
This makes Eclipse create a local settings file storing that setting within the project directory and that can be put under version control like other parts of the project. That way the setting will be available by all users of the project instantly. The following is an example of how things look like for me:
$PROJECT_NAME.settings\org.eclipse.wst.validation.prefs
DELEGATES_PREFERENCE=delegateValidatorList
USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator;
USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.web.validation.UIWarValidator;org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator;
USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.800.v201904082137
While additionally storing those settings in theory is against why one uses Gradle, because that should be able to generate those files when creating the project for Eclipse, it's the easiest way to make those settings available and their state documented using the SCM without implementing too much in build.gradle
.
Might be a good idea to vote on the bug in the Eclipse-bugtracker as well.