[SOLVED] 2.5.0.M2 troubles installing new JSR232/Jython support

I had it running on 2.4.0 inside a docker container.
I migrated the container to 2.5.0.M2 and got a lot of error messages when the old automation directory was loaded.

I scraped and pulled the Core/automation from openhab-helper-libraries.
When starting up I still get these log entries:

2019-08-11 16:40:23.825 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'javascript/core/000_startup_delay.js'
2019-08-11 16:40:35.123 [INFO ] [.script.lightControl Clean-Up .rules] - finished
2019-08-11 16:40:59.990 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/000_startup_delay.py'
2019-08-11 16:41:14.029 [INFO ] [jsr223.jython.core.startup_delay    ] - Checking for initialized context
2019-08-11 16:41:14.035 [INFO ] [jsr223.jython.core.startup_delay    ] - Context initialized... waiting 30s before allowing scripts to load
2019-08-11 16:41:44.039 [INFO ] [jsr223.jython.core.startup_delay    ] - Complete
2019-08-11 16:41:44.047 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/100_DirectoryTrigger.py'
2019-08-11 16:41:48.062 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/100_DirectoryTrigger.py': ImportError: No module named configuration in <script> at line number 21
2019-08-11 16:41:48.066 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/100_OsgiEventTrigger.py'
2019-08-11 16:41:49.982 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/100_OsgiEventTrigger.py': ImportError: No module named configuration in <script> at line number 17
2019-08-11 16:41:49.985 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/100_StartupTrigger.py'
2019-08-11 16:41:50.142 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/100_StartupTrigger.py': ImportError: No module named configuration in <script> at line number 16
2019-08-11 16:41:50.144 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/200_JythonBindingInfoProvider.py'
2019-08-11 16:41:50.567 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/200_JythonBindingInfoProvider.py': ImportError: No module named configuration in <script> at line number 19
2019-08-11 16:41:50.569 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/200_JythonExtensionProvider.py'
2019-08-11 16:41:52.422 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/200_JythonExtensionProvider.py': ImportError: No module named configuration in <script> at line number 29
2019-08-11 16:41:52.425 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/200_JythonItemChannelLinkProvider.py'
2019-08-11 16:41:52.720 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/200_JythonItemChannelLinkProvider.py': ImportError: No module named configuration in <script> at line number 18
2019-08-11 16:41:52.722 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/200_JythonItemProvider.py'
2019-08-11 16:41:52.885 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/200_JythonItemProvider.py': ImportError: No module named configuration in <script> at line number 10
2019-08-11 16:41:52.887 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/200_JythonThingProvider.py'
2019-08-11 16:41:53.131 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/200_JythonThingProvider.py': ImportError: No module named configuration in <script> at line number 17
2019-08-11 16:41:53.133 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/200_JythonThingTypeProvider.py'
2019-08-11 16:41:53.416 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/200_JythonThingTypeProvider.py': ImportError: No module named configuration in <script> at line number 17
2019-08-11 16:41:53.418 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/components/200_JythonTransform.py'
2019-08-11 16:41:53.641 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/core/components/200_JythonTransform.py': ImportError: No module named configuration in <script> at line number 19
2019-08-11 16:41:53.643 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/personal/hello-world.py'
2019-08-11 16:41:57.068 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/personal/hello-world.py': ImportError: No module named configuration in <script> at line number 3
2019-08-11 16:41:57.071 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/personal/testTimer.py'
2019-08-11 16:41:57.425 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/personal/testTimer.py': ImportError: No module named configuration in <script> at line number 1
2019-08-11 16:41:58.451 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/personal/testTimer.py'
2019-08-11 16:41:58.678 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/openhab/conf/automation/jsr223/python/personal/testTimer.py': ImportError: No module named configuration in <script> at line number 1

What did I forget to do?

Classpath is as in the previose setup

-Xbootclasspath/a:/openhab/conf/automation/jython/jython-standalone-2.7.0.jar -Dpython.home=/openhab/conf/automation/jython -Dpython.path=/openhab/conf/automation/lib/pytho

Step 8 :wink:

It’s an easy one to miss if you are updating.

2 Likes

RTFD.
You were faster, was just about point 8

1 Like

You’ve just been a little bit too early :slight_smile:

1 Like

That one bit me too.

Do I see it right:
mount local dir with this script to /etc/cont.init.d/ inside container as volume?

I did not find any real valuable description on google and docker docks about cont.init.d

Yes it works like a charm.

Thanks

btw its cont-init.d, not cont.init.d

Correct, that’s a typo :frowning:

I think the idea of the cont-init.d mount point may have come from the s6-overlay-builder project.

The 10-jsr223-jython script may get a little update once the Use simplified installation instructions for Python PR gets merged.

Seen that, but how is openhab container related to that?
Are all hooks described there implemented?

Finally found also reference to cont-init.d also here: Docker

The way it works is actually quite simple when you look at the entrypoint.sh script that is run when the container starts. Just before the openHAB start.sh script is run the following code is executed (I just noticed it even has ‘s6’ mentioned in the comment):

# Run s6-style init continuation scripts if existent
if [ -d /etc/cont-init.d ]
then
    for script in $(find /etc/cont-init.d -type f | grep -v \~ | sort)
    do
        . "${script}"
    done
fi

This will simply run any script found in the /etc/cont-init.d directory.

(source)

I’m working on an install script that also supports docker installs. I can’t give you a timeline though. As I’m sure you can infer, it will only require mounting libext to /openhab/runtime/lib/ext. I was going to post those updated instructions along side the installer but it has been taking me longer than I expected so I decided to post the new instructions as interest in JSR223 seems to be increasing.

This is somewhat of a philosophical question, but wouldn’t this script more properly be checked into the openhab/openhab-docker repo under contrib? There are already a number of cont-init.d scripts checked in there and it feels awkward to me to have these contributed init scripts scattered throughout the repos. It’s a script that is really only relevant for those running Docker.

It’s a great idea though and I will probably switch to it shortly. It solves the “how do I keep up with the helper library changes” problem, until such time as all of this becomes part of OH proper.

I’ve been going back on fort in my mind over this to be honest. I absolutely agree that we must avoid the situation where these kind of scripts are scattered all over the place and in the end everyone knows that they exist, but no one knows where to find them.

What made me decide to PR them towards the helper libraries repository is that the documentation of the helper libraries is also stored in that repository. I intend to update the installation instruction once this is merged. It feels a bit awkward to point to another repository to obtain the scripts.

On the other hand, if people just go to the documenation at https://openhab-scripters.github.io/openhab-helper-libraries/index.html then they may not even go to the Github repository and then it probably would be better if they are stored in the openHAB-Docker repository.

Choices, choises :wink:

@5iver @cniweb @wborn Do you have any thoughts on this?

I like the idea of having scripts to simplify the installation of Jython and Groovy, and to install and upgrade the HLs. I think the best place for scripts like this to reside would be in the HL repo, but I also think it makes sense to have an easy way to launch them using the official openhab Docker containers and openHABian.

However, there would need to be a lot of effort to build, educate, and support this, and the reality is that they will become obsolete once the Jython and Groovy addons have been completed. So, my recommendation and preference ATM is to hold off on scripts and redirect the effort into the addons, which have unfortunately become stagnated by the BND debacle.

I haven’t made the time to review your PR yet, but I hope to get to it this weekend.

No worries about the scripts becoming obsolete. Over the past 23 years working for a large multinational I’ve grown used to building stuff that never makes it into production. If until the addons are made available the scripts helps anyone, great. If not, they still help me because I’m using them :slight_smile:

I got some good feedback on the PR so I’ll try to incorporate that before the weekend.

2 Likes

In order to rule out an issue I have with the TRADFRI binding, I decided to reinstall OH2.5 (MS2) on a brand new Buster-based openhabian distro.

This also involves reconfiguring the JSR223 environment.

I now run into the same problem as others in the thread reported: “ImportError: No module named core in at line 5”.
When using the helo_world.py file, here’s the error log I get:

==> /var/log/openhab2/openhab.log <==
2019-09-04 21:42:37.543 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script ‘python/personal/hello_world.py’
2019-09-04 21:42:37.548 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language ‘py’ with identifier: file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py
2019-09-04 21:42:37.570 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - Script loaded: python/personal/hello_world.py
2019-09-04 21:42:37.826 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - in queue: {md=[file:/etc/openhab2/automation/jsr223/python/personal/README.md, file:/etc/openhab2/automation/jsr223/python/community/README.md]}
2019-09-04 21:42:37.848 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script ‘python/personal/hello_world.py’
2019-09-04 21:42:37.854 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language ‘py’ with identifier: file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py
2019-09-04 21:42:37.878 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - Script loaded: python/personal/hello_world.py
2019-09-04 21:42:38.933 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - in queue: {md=[file:/etc/openhab2/automation/jsr223/python/personal/README.md, file:/etc/openhab2/automation/jsr223/python/community/README.md]}
2019-09-04 21:42:38.936 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script ‘python/personal/hello_world.py’
2019-09-04 21:42:38.940 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language ‘py’ with identifier: file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py
2019-09-04 21:42:39.131 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script ‘file:/etc/openhab2/automation/jsr223/python/personal/hello_world.py’: ImportError: No module named core in at line number 5
2019-09-04 21:42:39.135 [DEBUG] [rt.internal.loader.ScriptFileWatcher] - Script loaded: python/personal/hello_world.py

File and dir permissions are correct.

Okay, I found the culprit.

The openhabian-config script apparently reverted the edit I made in /etc/default/openhab2 to add the JSR/Jython stuff… I suspect it doesn’t check if the EXTRA_JAVA_OPTS are already set, and hence overwrites it to set Xms and Xmx values for the JVM.

Case closed.