In the documentation it states groovy, python and ruby can be used. It shows which dependency is required for groovy but not python and ruby.
What is required for python? Just PYTHON_HOME?
Thanks.
In the documentation it states groovy, python and ruby can be used. It shows which dependency is required for groovy but not python and ruby.
What is required for python? Just PYTHON_HOME?
Thanks.
Hi,
You need Jython on the DMN engineās classpath. See http://mvnrepository.com/artifact/org.python/jython/2.7.0 for the Maven coordinates.
Cheers,
Thorben
Cool Thanks
Does the python script have access to the process objects? For example: ${order.price}
Getting an error āCanāt find scripting engineā
The jython 2.7.0 jar is in tomcat/lib and also in the pom.
Hi,
how did you specify the language to use. Could you attach your DMN file and the full stacktrace?
Cheers,
Sebastian
I followed the documentation here:
https://docs.camunda.org/manual/7.4/user-guide/process-engine/decisions/configuration/
Replaced āgroovyā with āpythonā
But Im still seeing the error "Canāt find scripting engine āpythonā: scriptEngine is null
Hi,
I think I can reproduce that. Would you mind to test if you have the same issue with the jython-2.5.3.jar? Iām not sure why but 2.5.3 works for me whereas with 2.7.0 no script engine is found. I have to debug this to understand the root cause.
Cheers,
Sebastian
Hi,
sorry for the confusion I now remember that they change the site.py loading with jython 2.7.0. So there are at least 3 ways to use jython 2.7.0.
python.import.site=false
to disable site package loading, i.e. JAVA_OPTS=-Dpython.import.site=false ./apache-tomcat-8.0.24/bin/catalina.sh run
JYTHONPATH=/usr/lib/python2.7/ ./apache-tomcat-8.0.24/bin/catalina.sh run
Does this solve the issue for you?
Cheers,
Sebastian
Switching to jython 2.7.0 standalone fixed the issue.
Thanks.
Hi @menski! Iām not a Java dev and trying to use JavaScript or Python scripting in Camunda.
I cannot get it to work and the Docs arenāt helping (prob due to my lack of Java/Wildfly knowledge).
As it says here there is the option to either:
I am confused, I tried adding jython-standalone-x.jar to /lib (using WildFly) > ScriptEngine not found error
Then I added jython-standalone-x.jar to my servlet-war maven project through maven dependency > ScriptEngine not found.
Do you have a guide (steps/link) how to add a scripting engine (pref for global use) under WildFly?
Thanks a million!
Hi @Lxnd,
on Wildfly there is no global lib folder. Wildfly uses modules and has an more explicit dependency system.
So if you want to use jython you have to add a jython module to the wildfly and import it in module you want to use it. You can have a look at the modules we use for our testing environments. There we add jython 2.5 and add it as dependency to the camunda-engine module. If you want to use the dmn-engine standalone you would add it to the camunda-engine-dmn module.
Btw javascript should work out of the box as it is part of the jdk and no external dependency. Could you share your environment (camunda & jdk version), process or decision and the error you are receiving?
Cheers,
Sebastian
Hi @menski
Thanks for those Wildfly links, got to read up on itā¦
Indeed the Javascript works out of the box, great!
I am using JDK 1.8.0_92 and Camunda 7.5.0_a4 (indeed bleeding edge ) on Wildfly 10
Regarding use of Jython:
Does this mean I have to re-compile camunda-engine myself with the added dependencies you mention above or can I āreuseā an existing Camunda distro and run e.g. jboss-cli:
jboss-cli (to get JBoss shell)
$ connect
$ module add --name=org.python.jython --resources=D:\Dev\jython-standalone-2.7.1b3.jar --dependencies=javax.api
(this still gives the error below btw)
An error happend while submitting the task form :
Cannot submit task form 967abd42-1dd3-11e6-b0b1-22c9d095bc69: Canāt find scripting engine for ājythonā: scriptEngine is null
With accompanying CLI error:
17:09:01,011 ERROR [org.camunda.bpm.engine.context] (default task-11) ENGINE-16004 Exception while closing command context: Canāt find scripting engine for ājythonā: scriptEngine is null: org.camunda.bpm.engine.exception.NullValueException: Canāt find scripting engine for ājythonā: scriptEngine is null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
ā¦
17:09:01,026 WARNING [ExceptionHandler] (default task-11) org.camunda.bpm.engine.rest.exception.RestException: Cannot submit task form 967abd42-1dd3-11e6-b0b1-22c9d095bc69: Canāt find scripting engine for ājythonā: scriptEngine is null
at org.camunda.bpm.engine.rest.sub.task.impl.TaskResourceImpl.submit(TaskResourceImpl.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
ā¦
Caused by: org.camunda.bpm.engine.exception.NullValueException: Canāt find scripting engine for ājythonā: scriptEngine is null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
Am 99.9% sure the error is triggered by this DMN in my process flow:
decisions_1.dmn (2.0 KB)
Thanks for your advice!
Hi,
you have to add the jython dependency to the camunda wildfly module.xml you want to use it with. You donāt have to recompile it. You have to add it to the camunda-engine wildfly module.xml if you use the BPMN engine to call a decision task which will use the DMN engine. If you have an own application which uses the DMN engine by itself in standalone mode I think you have to add it to the camunda-engine-dmn wildfly module.xml. As you are using the execution variable in the script I think you use it in the Context of the BPMN engine so the former applies.
As a side note: If I remember correctly it is not possible to return something from a python script. It either hast to be an expression or you have to choose an other language I guess.
Cheers,
Sebastian
Got it to work
For those struggling with the same: in order to use scripting engine Python/Jython (or Ruby/JRuby for that matter) on WildFly (Camunda 7.5.0_Alpha + WildFly 10) follow these steps:
jython-standalone
so I didnāt have to deal with dependencies)start-camunda
server\wildfly-XXXversion\bin\jboss-cli
(and type connect
after you are in the JBoss shell)--resources
with correct path)*:module add --name=org.python.jython --resources=D:\Dev\jython-standalone-2.7.1b3.jar --dependencies=javax.api
server\wildfly-XXXversion\org\camunda\bpm\camunda-engine\main\module.xml
and add the following below the line that contains groovy-all
:<module name="org.python.jython" services="import"/>
jboss-cli
and youāll have to restart your wildfly server completely, but that should do the trick!Now since Python/Jython doesnāt return variables from scripts according to @menski, I guess Iāve got to get my JavaScript book off of the top bookshelf
*) for JRuby see here
NOTE: the above should work the same for JBoss (obviously) and is all thanks to @menski answering my Qās!
Hi @Lxnd,
thanks for sharing this nice summary.
You could still use python to evaluate a single expression like foo > 12
.
Cheers,
Sebastian