Calling Javascript classes before script execution


we are currently using the Camunda Engine as wildfly module within our application. We have defined some Javascript classes which we would evaluate before executing the script defined in a script task in the BPMN workflow.

We have added a custom ScriptEngineFactory and evaluated those javascript classes in this script engine but somehow they are not known while executing the scripts.

Any ideas ?



Hi Asad,

I am not sure I understand the question. You want to invoke some javascript out of another script? Could you may be publish a small example somewhere?


Sure… This is my custom ScriptEngineFactory:
public class TestScriptEngineFactory implements ScriptEngineFactory {

public List getNames() {
List names = new ArrayList<>(factory.getNames());
return names;

public String getLanguageName() {
return “test”;

public String getLanguageVersion() {
return “1.0.0”;

public ScriptEngine getScriptEngine() {
ScriptEngine nse = factory.getScriptEngine(classFilter);
try {

} catch (ScriptException e) {
  throw new KolibriException("failed to create Kolibri script engine", e);
return nse;




I’m expecting that the camunda engine evaluate my code nse.eval(getScriptLibraries()); before executing the javascript in the script task.
I have put my script engine “test” into the task in the field Script format which seems to work but still it fails to evaluate my scriptlibraries before the execution of the java script in the script task. I guess the variables are not in the right scope but i’m not sure.

Thanks for your help!