How to Setup Jython

I noticed in post #17 inside python you have openhab only and I have esper and openhab. Not sure what that means but moving it to a temp dir didn’t seem to change anything.
Here’s what it looks like now, notice the openhab2-conf (this may be due to samba share)
Screenshot%20at%202018-10-09%2010-30-35

I’ve also tried changing permission in automation/lib/python/openhab for all files so they matched triggering.py (chmod a+x on all) No change.

Did you notice my earlier log, at the top, BundleEvent [unknown:512]?

I have some free time so I’ll keep poking around, can’t break broke.:grin:

This is what causes the log entry, but I haven’t figured out why the script engine wouldn’t be loaded.

My gut is telling me it is a timing issue. My production system is running the same OH and does not have the issue. I may try loading up the test system to slow down the startup.

The only way I’ve been able to get the logs above is having .jar in /usr/share/openhab2/runtime/boot. I guess this is OK for now?

Any idea what may be causing “ImportError: No module named openhab in <script> at line number 4” on all scripts in jsr223/000_components?

Same issue. You moved the Jython jar into the classpath, but OH is not able to see the modules. You will want to go back to the way it is described in the doc. Just need to figure out why the engine isn’t loading.

I tried doing JSR223 about a month ago and ended up messing up the entire OH install.

Ready to try again, fresh Openhabian install on PI3B. Have reviewed many threads on how to do it but there seems to be conflicting information and I am not sure what to do.

Python3 is installed on the PI from using another program. Its installed in /usr/lib/python3

Do I need to upgrade from OH2.3? What JAR do I need?

Mike

I’m happy to help, but there may be an issue in the latest snapshot. You will want to be on a recent snapshot or milestone build. This is where I suggest to start…

… so you can use this…

Hi Scott,

Still a relative OH and Linux newbie…so bare with me…

I am on 2.3 - Release Build. Do I need to be on the 2.4 package?

The only stupid question is the one you don’t ask… unless it was if I’d like a :beer:!

Need… no. Want… yes. I tried to explain in the readme. The Automation API has been pretty well reworked in the OH 2.4 snapshot builds, which some has made into the test/milestone builds. The decorators I wrote will need the updated API.

ok, i’ll upgrade to the snap shot build.

@5iver I’m testing on a RPI 2 maybe Michael’s RPI 3 will work?

Another piece to the puzzle… Javascript rules are working.

I’m testing on an i7, so hardware does not seem to be the issue. :wink:

1 Like

Yes, rules seem to work. Here’s the rule from this morning and it runs on each restart.

2018-10-09 11:21:00.610 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script '000_startup.py'

2018-10-09 11:21:00.773 [INFO ] [eclipse.smarthome.model.script.Rules] - JSR223: Startup: Checking for initialized context

2018-10-09 11:21:00.795 [INFO ] [eclipse.smarthome.model.script.Rules] - JSR223: Startup: context initialized... waiting 30s before allowing files to load

2018-10-09 11:21:30.799 [INFO ] [eclipse.smarthome.model.script.Rules] - JSR223: Startup: Complete

i’ll let you know - hopefully in the next hour or so

This is what we are looking to see in the log on startup (from my production box)…

2018-10-05 23:58:01.531 [INFO ] [org.eclipse.smarthome.automation.module.script.internal.GenericScriptEngineFactory] - Activated scripting support for ECMAScript
2018-10-05 23:58:01.539 [DEBUG] [org.eclipse.smarthome.automation.module.script.internal.GenericScriptEngineFactory] - Activated scripting support with engine Oracle Nashorn(1.8.0_181) for ECMAScript(ECMA - 262 Edition 5.1) with mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript] and file extensions [js]
2018-10-05 23:58:01.540 [INFO ] [org.eclipse.smarthome.automation.module.script.internal.GenericScriptEngineFactory] - Activated scripting support for python
2018-10-05 23:58:01.548 [DEBUG] [org.eclipse.smarthome.automation.module.script.internal.GenericScriptEngineFactory] - Activated scripting support with engine jython(2.7.0) for python(2.7) with mimetypes [text/python, application/python, text/x-python, application/x-python] and file extensions [py]

From test system (no Jython)…

2018-10-09 12:58:05.990 [INFO ] [.internal.GenericScriptEngineFactory] - Activated scripting support for ECMAScript
2018-10-09 12:58:05.991 [DEBUG] [.internal.GenericScriptEngineFactory] - Activated scripting support with engine Oracle Nashorn(1.8.0_181) for ECMAScript(ECMA - 262 Edition 5.1) with mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript] and file extensions [js]

I’m starting to think there’s something silly stupid that we’re missing, but I’ve checked everything I can think of between my two systems and they appear setup the same.

Just restarted to verify with debug on and looks like everything is there.

2018-10-09 12:12:04.390 [INFO ] [.internal.GenericScriptEngineFactory] - Activated scripting support for python

2018-10-09 12:12:04.412 [DEBUG] [.internal.GenericScriptEngineFactory] - Activated scripting support with engine jython(2.7.0) for python(2.7) with mimetypes [text/python, application/python, text/x-python, application/x-python] and file extensions [py]

2018-10-09 12:12:04.417 [INFO ] [.internal.GenericScriptEngineFactory] - Activated scripting support for ECMAScript

2018-10-09 12:12:04.431 [DEBUG] [.internal.GenericScriptEngineFactory] - Activated scripting support with engine Oracle Nashorn(1.8.0_152) for ECMAScript(ECMA - 262 Edition 5.1) with mimetypes [application/javascript, application/ecmascript, text/javascript, text/ecmascript] and file extensions [js]

Oracle Nashorn(1.8.0_152) your version is newer but that’s the only thing I see different.

I removed the jar file from /boot and checked that I only had one jar on the system. The cache and tmp are clean.
Now I’m missing Activated scripting support for python, ECMAScript is good but now it’s back to “ScriptEngine for py not available”

Where is your start.sh file located? Hopefully in /etc/openhab2/.

Start.sh is located in /usr/share/openhab2

O man… I knew it was going to be silly stupid :roll_eyes:. I thought using the DIRNAME variable in start.sh would help in case someone had a non-standard installation. It is defined as…

DIRNAME=`dirname "$0"`

This gives it the value of the path used to launch the script, and I’ve been using ./start.sh, so the paths were all messed up and the Jython script engine never loads!

You have a similar issue… I assumed incorrectly that the apt installs had start.sh in /etc/openhab2. SO… the solution is to just use this in your EXTRA_JAVA_OPTS…

export EXTRA_JAVA_OPTS="-Xbootclasspath/a:/etc/openhab2/automation/jython/jython-standalone-2.7.0.jar \
-Dpython.home=/etc/openhab2/conf/automation/jython \
-Dpython.path=/etc/openhab2/conf/automation/lib/python"