JSR223 - Can't find jython

Hi Everyone,

I’m having trouble setting up jython with the JSR223 engine under OpenHAB 1.7.1 and Java 8. I have installed jython into /opt/jython from the installer package and symlinked it into /usr/share/openhab/lib. I’ve also added the -Dpython.home argument in /etc/default/openhab, but it still doesn’t get found.

My debug logs are showing the following relating to jsr223:

21:30:01.938 [DEBUG] [j.internal.Jsr223CoreActivator:33 ] - Registered ‘jsr223’ scripting-engine
21:30:01.941 [DEBUG] [j.internal.engine.Jsr223Engine:96 ] - itemRegistry set
21:30:01.942 [DEBUG] [j.internal.engine.Jsr223Engine:68 ] - activate()
21:30:01.957 [INFO ] [o.o.c.j.i.e.s.ScriptManager :58 ] - Available engines:
21:30:01.973 [INFO ] [o.o.c.j.i.e.s.ScriptManager :60 ] - Oracle Nashorn
21:30:01.975 [INFO ] [o.c.j.i.e.scriptmanager.Script:71 ] - Loading Script notifications.py
21:30:01.988 [DEBUG] [j.internal.engine.Jsr223Engine:78 ] - Started Jsr232 engine

I really have no idea what is going on, I must be missing something. Can anyone help?

Are you sure the jython jar file is being added to the classpath in your startup script?

Yes, I also looked at that and added -cp /usr/share/openhab/lib/jython.jar to the JAVA_OPTIONS variable in /etc/default/openhab.

I had previously added some missing files to my jsr223 jar file in order to get the JS interpreter working, since the version in the Apt repo was broken. Perhaps I should just install from a different source? Where did you get the jar file from?

I got the jython.jar from the Jython download site. I forget whether I downloaded the standalone or the installer version of it.

Also, I manually installed my openhab software so my paths and startup scripts are probably different than yours.

Thanks Steve, however I was more referring to the JSR223 .jar file. I saw something about the released version missing the OSGI-INF directory, which I think was the change I made. I was wondering if there is one that works ‘out of the box’?

you can find a working version at cloudbees: https://openhab.ci.cloudbees.com/job/openHAB/


Thank you! I will give that a try tonight.

Sorry Rob, I misunderstood the question. I’m using a 1.8.0-SNAPSHOT jar that I built locally so hopefully the cloudbees jar will work for you.

OK, I’ve installed the 1.8.0 snapshot into my addons folder, but it seems still not to work. I now get the additional message:

21:52:05.533 [WARN ] [o.o.c.j.i.e.s.ScriptManager :92 ] - No Engine found for File: notifications.py

…just before the “Started jsr223” message.

Is anyone running jsr223+jython successfully on 1.7.1?

EDIT: As further info I submit the java command line of my OH process to aid debugging:

/usr/bin/java -Dlogback.configurationFile=/etc/openhab/logback.xml -cp /usr/share/openhab/lib/jython.jar -Dpython.home="/opt/jython" -Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Djetty.port=8081 -Dopenhab.configfile=/etc/openhab/configurations/openhab.cfg -Dopenhab.configdir=/etc/openhab/configurations -Dopenhab.logdir=/var/log/openhab -Dsmarthome.userdata=/var/lib/openhab -Djetty.home=/usr/share/openhab -Djetty.port.ssl=8443 -Djetty.config=/etc/openhab/jetty -Djetty.logs=/var/log/openhab -Djetty.rundir=/usr/share/openhab -Dfelix.fileinstall.dir=/usr/share/openhab/addons -Dfelix.fileinstall.filter=.*\.jar -Djava.library.path=/usr/share/openhab/lib -Djava.security.auth.login.config=/etc/openhab/login.conf -Dorg.quartz.properties=/etc/openhab/quartz.properties -Dequinox.ds.block_timeout=240000 -Dequinox.scr.waitTimeOnBlock=60000 -Dfelix.fileinstall.active.level=4 -Djava.awt.headless=true -jar /usr/share/openhab/server/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar -configuration /var/lib/openhab/workspace -data /var/lib/openhab/workspace -console 5555

That message is just a side-effect of not loading the Jython engine.

I don’t see anything obviously wrong. I am running 1.7.1 with a 1.8.0 JSR223 addon. As an experiment, you could try pointing your classpath directly to the jython.jar in /opt/jython. Given that you have Nashorn engine, that indicates that the JSR223 addon is loading correctly. It’s just not finding the Jython engine.

Take a look at…

I’m using the same technique in my startup script where I don’t use the -jar option and instead add the eclipse launcher to the classpath and run org.eclipse.equinox.launcher.Main.

Thanks for that Steve, I’ll give it another try tonight.

w00t! I finally have it working (complete with test rule execution).

As you said I needed to add the eclipse launcher to the classpath and call org.eclipse.equinox.launcher.Main. I have an updated start script to this effect, which also allows you to specify a CLASSPATH variable in /etc/defaults/openhab. I will post this as part of a bug report over the weekend.

Thanks for all your help!