Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix for Grails10425 #403

wants to merge 1 commit into from

3 participants


Fix for Grails10425.Removed contextPath from uri. The existing tests pass , however need a strategy to set context path for testing.


We'll need a better fix, as we can't depend on WebRequest within the renderers


One possible way is to expose a method in RenderContext that can give the original request URL. Let me know if that works and I may be able to resubmit the PR.


Yes you can provide things through the render context, but directly referencing the servlet API specific stuff is a no no

@lhotari lhotari closed this
@lhotari lhotari reopened this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
6 grails-plugin-rest/src/main/groovy/grails/rest/render/hal/HalJsonRenderer.groovy
@@ -24,6 +24,7 @@ import groovy.transform.CompileStatic
import org.codehaus.groovy.grails.web.binding.bindingsource.DataBindingSourceRegistry
import org.codehaus.groovy.grails.web.binding.bindingsource.HalJsonDataBindingSourceCreator
import org.codehaus.groovy.grails.web.mime.MimeType
+import org.codehaus.groovy.grails.web.util.WebUtils
import org.grails.datastore.mapping.model.PersistentEntity
import org.grails.datastore.mapping.model.types.Association
import org.grails.datastore.mapping.model.types.ToOne
@@ -164,7 +165,10 @@ class HalJsonRenderer<T> extends AbstractLinkingRenderer<T> {
protected void writeLinkForCurrentPath(RenderContext context, MimeType mimeType, JsonWriter writer) {
- final href = context.resourcePath, method: HttpMethod.GET.toString(), absolute: absoluteLinks)
+ final uriWithoutContext = context.resourcePath.substring(
+ WebUtils.retrieveGrailsWebRequest().contextPath.length())
+ final href = uriWithoutContext, method: HttpMethod.GET.toString(),
+ absolute: absoluteLinks)
final resourceRef = href
final locale = context.locale
def link = new Link(RELATIONSHIP_SELF, href)
Something went wrong with that request. Please try again.