New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.mozilla.javascript.EcmaError: ReferenceError for function #19

lutzhorn opened this Issue Oct 30, 2017 · 1 comment


None yet
2 participants

lutzhorn commented Oct 30, 2017

Consider this code:

var lib = {
	foo: function(node) {
		logger.debug("" +;

var sql = "select 'workspace://SpacesStore/af9f95ac-dfdd-4787-b044-22e2026c4e74'"; // some existing NodeRef

var result = database.query("dataSource", sql);

var nodesToMigrate = [];

for each (var row in result) {
    var node = search.findNode(row[0]);
    if (!node || !node.exists()) {

var process = function process(node) {"processing " + node.typeShort + " " + node.nodeRef);

    // calling function from `lib` fails!;

var beforeProcessFunction = function beforeProcess() {

var afterProcessFunction = function afterProcess() {

batch.runForNodes('Process-', 2, 10, nodesToMigrate, process, true, beforeProcessFunction, afterProcessFunction);

Observed Behaviour

This will throw

Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "lib" is not defined. (AlfrescoJS#4)
        at org.mozilla.javascript.ScriptRuntime.constructError(
        at org.mozilla.javascript.ScriptRuntime.constructError(
        at org.mozilla.javascript.ScriptRuntime.notFoundError(
        at org.mozilla.javascript.gen.AlfrescoJS_108._c_process_1(AlfrescoJS:4)
        at org.mozilla.javascript.optimizer.OptRuntime.callName(
        at org.mozilla.javascript.gen.AlfrescoJS_108._c_script_0(AlfrescoJS:7)
        at org.mozilla.javascript.ContextFactory.doTopCall(
        at org.mozilla.javascript.ScriptRuntime.doTopCall(
        at org.mozilla.javascript.gen.AlfrescoJS_108.exec(AlfrescoJS)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(
        ... 29 more

Expected Behaviour

The function is executed.


This comment has been minimized.

Show comment
Hide comment

jgoldhammer Nov 27, 2017


I do not know if we can fix that?! Any ideas?


jgoldhammer commented Nov 27, 2017

I do not know if we can fix that?! Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment