Sep 14, 2010

Unlimited unbinding loop when using ObjectId

Just got the following error in my play templates:

RuntimeException occured : java.lang.StackOverflowError

play.exceptions.JavaExecutionException: java.lang.StackOverflowError
at play.mvc.ActionInvoker.invoke(
at Invocation.HTTP Request(Play!)
Caused by: java.lang.RuntimeException: java.lang.StackOverflowError
at play.templates.BaseTemplate.throwException(
at play.templates.GroovyTemplate.render(
at play.mvc.results.RenderTemplate.(
at play.mvc.Controller.renderTemplate(
at play.mvc.Controller.renderTemplate(
at play.mvc.Controller.render(
at controllers.CKBoxes.index(
at play.mvc.ActionInvoker.invokeControllerMethod(

at play.mvc.ActionInvoker.invokeControllerMethod(

at play.mvc.ActionInvoker.invoke(
... 1 more
Caused by: java.lang.StackOverflowError
at java.lang.Class.privateGetDeclaredFields(
at java.lang.Class.getDeclaredFields(

The problem happens when Unbinder tries to unbind a static field called _nextInc of type org.bson.types.ObjectId:

private static AtomicInteger _nextInc

In AtomicInteger there is a reference to sun.misc.Unsafe which in turn refer to a field with the same type: sun.misc.Unsafe

So what should be the solution? Here are what comes in my mind at the moment:
1. Unbinder do not try to unbind a static field ?
2. Some mechanism should be implemented in Unbinder to prevent endless unbinding loop like this case

As a temporary workaround I add ".toString()" to explicitly get String represent of ObjectId object:

original: #{a @{edit(}edit{/#}
workaround: #{a @{edit(}edit{/#}

No comments:

About Me

My photo