AnsweredAssumed Answered

No top level scope?

Question asked by cs02rm0 on Mar 22, 2013
Latest reply on Oct 14, 2015 by electroshokker
Hi

I'm reworking a Javascript webscript into a Java one. The Java one now extends DeclarativeWebscript and returns a Map of Lists of Maps, etc. down to a ScriptNode.

item.put("node", new ScriptNode(nodeRef, _serviceRegistry));


The freemarker which takes the model from the Java is erroring:


Caused by: freemarker.template.TemplateModelException: get(properties) failed on instance of org.alfresco.repo.jscript.ScriptNode

Caused by: java.lang.reflect.InvocationTargetException

Caused by: java.lang.NullPointerException
   at org.mozilla.javascript.ScriptableObject.getTopLevelScope(ScriptableObject.java:1483)
   at org.mozilla.javascript.ScriptRuntime.setObjectProtoAndParent(ScriptRuntime.java:3106)
   at org.mozilla.javascript.Context.newArray(Context.java:1547)
   at org.alfresco.repo.jscript.ValueConverter.convertValueForScript(ValueConverter.java:121)
   at org.alfresco.repo.jscript.ScriptNode$NodeValueConverter.convertValueForScript(ScriptNode.java:3258)
   at org.alfresco.repo.jscript.ScriptNode$NodeValueConverter.convertValueForScript(ScriptNode.java:3237)
   at org.alfresco.repo.jscript.ScriptNode.getProperties(ScriptNode.java:835)
   … 116 more


Any suggestions on why there isn't a top level scope / how I can get one? Thanks.

Outcomes