[GRADLE-1130] Missing context-root property in WTP settings Created: 25/Aug/10  Updated: 04/Jan/13  Resolved: 24/Nov/10

Status: Resolved
Project: Gradle
Affects Version/s: 0.9
Fix Version/s: 0.9-rc-3

Type: Bug
Reporter: Felix Gnass Assignee: Hans Dockter
Resolution: Fixed Votes: 0


 Description   

Eclipse stores the context-root inside a property within the org.eclipse.wst.common.component file. The value corresponds to the "Properties > Web Project Settings > Context root" setting. If the property tag is not present, Eclipse sets the value to null internally and reports an error in the Properties dialog: "Context root cannot be empty".

In Eclipse 3.6 the server starts in spite of the error, whereas in Eclipse 3.5 Tomcat startup fails. The reason is that Eclipse deploys the webapp to wtpwebapps/tmp0/ROOT but Tomcat expects it in wtpwebapps/tmp0/foo, with 'foo' being the context-root property.

This is what org.eclipse.wst.common.component looks like after setting the value via the UI:

<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="riot-skeleton">
<property name="context-root" value="foo"/>
...
</project-modules>

Workaround:

eclipseWtp.withXml { files ->
def xml = files.'org.eclipse.wst.commons.component'
xml['wb-module'][0].appendNode('property', [name: 'context-root', value: 'foo'])
}



 Comments   
Comment by matt smalley [ 26/Oct/10 ]

Workaround is giving me an error:

Could not compile build file '/home/msmalley/Projects/test-gradle/build.gradle'.
Cause: startup failed:
build_gradle_1d07d0bd0d215f605ecab4fdca0e6a69: 33: expecting '}', found 'xml' @ line 33, column 73.
   clipse.wst.commons.component' xml['wb-mo

with a marker under the 'x' in 'xml'. I'm started with the eclipse example, so my version actually looks like:

eclipseWtp {
	withXml { xml -> xml.'org.eclipse.wst.commons.project.facet.core'.fixed.find { it.@facet == 'jst.java' }.@facet = 'jst2.java' }
	withXml { files -> def xml = files.'org.eclipse.wst.commons.component' xml['wb-module'][0].appendNode('property', [name: 'context-root', value: 'foo']) }
}

I'm new to gradle and groovy as well, but I took a stab in the dark and replaced the space preceding xml with a '.' which gives me a new error:

Execution failed for task ':eclipseWtp'.
Cause: Failed to notify action.
Cause: Cannot invoke method appendNode() on null object

At this point I'm not exactly sure which is closer to correct, so I'm deferring to the experts

Comment by Assaf Berg [ 11/Nov/10 ]

You should replace it with a newline.

eclipseWtp.withXml { files ->
def xml = files.'org.eclipse.wst.commons.component'
xml['wb-module'][0].appendNode('property', [name: 'context-root', value: 'foo'])
}

Generated at Wed Jun 30 11:47:40 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.