[Windows] All OH logs stop when Jython is in the classpath

Hi,

Congratulations to all the developers on Openhab, I have been experimenting with it over the past few months. It is very addictive. Unfortunately I have run into an issue I cannot resolve.

  • Platform information:
    • Hardware: Intel Core i3, 8GB Memory, Intel NUC
    • OS: Windows 10
    • Java Runtime Environment: Zulu8.25.0.3 (I tried a 32 and 64 bit version also)
    • openHAB version: 2.5 M2 New ‘standard’ install. No binding, things etc…
  • Installed: Experimental rule engine

I’ve attempted to install jython scripting so I can write my rules in Python. I followed these two guides here:

https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html

and:

However, as soon as I place the jython-standalone .jar file in conf\automation\jython and restart Openhab all logging stops. For example when I log:tail in the console I get nothing.

If I delete the jython-standalone .jar file and restart Openhab again, log:tail produces all the usual output. It also shows all the ServiceEvents REGISTERED of all the .py files etc… But when I save a .py file it of course says ScriptEngine for py not available

Maybe surprisingly Openhab seems to be running ok, even when I get no logs. The various interfaces all work, and sensor data seems to come through. So it would seem that only the logging is broken.

In the userdata\logs folder I do not see the timestamp updated either. The timestamp stays the same as the last time Openhab ran.

I have tried:

  • restoring the log config file org.ops4j.pax.logging.cfg on my ‘production’ version of Openhab (I saw this on some other threads)
  • deleting tmp, cache folders at various stages
  • a completely empty ‘standard’ fresh install using 2.5 M2 version (only with experimental rule engine installed)
  • setting EXTRA_JAVA_OPTS as env variable, and in the start.bat file:

-Xbootclasspath/a:D:\OpenHAB\openHAB_2-5_M2\conf\automation\jython\jython-standalone-2.7.1.jar -Dpython.home=D:\OpenHAB\openHAB_2-5_M2\conf\automation\jython -Dpython.path=D:\OpenHAB\openHAB_2-5_M2\conf\automation\lib\python

  • Tried jython 2.7.0, 2.7.1

Unfortunately without the logs, finding the problem becomes rather difficult.

Has anyone come across this before? If you have any other ideas I would love to hear them, as I have run out! :laughing:

Many thanks!

2.5M2 is the new TESTING version. The STABLE version is 2.4.
I know there are a couple of expected problems with the current test version.
I do not recall hearing anything script related either way.

This was the first thing that came to mind…

But when I observed this, the logs were working. I haven’t tested on a Windows install in a couple months, so this could be something new. I’ll boot over to Windows and take a look sometime later today.

Are you missing the set EXTRA_JAVA_OPTS= from the beginning of this line? From the docs…

REM Add to the top of the file
set EXTRA_JAVA_OPTS=-Xbootclasspath/a:C:\openhab2\conf\automation\jython\jython-standalone-2.7.0.jar -Dpython.home=C:\openhab2\conf\automation\jython -Dpython.path=C:\openhab2\conf\automation\lib\python

Thanks for the replies…

@Bruce_Osborne I will try with 2.4 again. I can’t recall why I moved to 2.5. I think because of a particular binding I needed. But worth a try again.

@5iver The path I posted was just the value of the environment variable I set. So yes has that EXTRA_JAVA_OPTS as the variable name. Thanks for the ticket will take a look…

I tried the same setup with 2.4, and it works. So must be something with 2.5

I think I moved to 2.5 because I use a Conbee2 dongle, and there were some issues on 2.4 with the deconz binding I read here:

I’ll try some things, see if I can work it out…

I finally booted into Windows and was amazed that I could reproduce this. However, by fiddling around and restarting OH a bunch of times, the logs worked again. I’ll look into it some more and open an issue if I can’t figure out the cause/fix.

Cool at least it wasn’t just my setup. I’ll try some rounds of restarting…

Thanks so much for looking into it.

1 Like

@gjj81 I am having the same issues as you.

https://community.openhab.org/t/jsr223-jython-breaks-karaf-or-logging/80351

Any luck with fiddling around with things or trying multiple restarts of OH? I have had no luck. For me I went to OH2.5 so that I wouldn’t have to change setenv.bat, and I’d be in the correct future configuration for the start.bat file. (See this post from @5iver).

https://community.openhab.org/t/windows-using-extra-java-opts/75624

I’d rather not go back to 2.4 because I already reconfigured my rules for the new mail binding which seemed to replace the mail action in 2.5. But, I can if I have to.

Another option would be to run in a Linux VirtualBox VM with a bridged NIC. That is how I started evaluating OH.

@Bruce_Osborne, I’ve considered this, but this is only my test box, I mess around with the new stuff when I’m on the road. My actual home setup is a linux NAS that I built. It works great and once stuff is running smooth on windows I port it over to that box. Not ideal probably, but hadn’t had a problem like this until now.

One more update, just for kicks I went in and actually edited the setenv.bat file, and as I expected it didn’t change the result. I’m pretty sure that I’m actually getting the environment set up correctly, and that there is an underlying error that’s causing the logging break. Just like @gjj81, if I look through my logfiles, there are no updates whatsoever while this error is in effect. Only ERROR level logs print out on the Karaf console in real time, and their formatting is all wrong, but don’t get logged to files.

@stagf15 Unfortunately I didn’t have any luck.

I tried in 2.4, which seemed to work fine. But I needed 2.5 for my Conbee2 dongle.

I may try moving to Linux or WSL2 on Windows or some combination of. I just need to reconfigure some things on my network a bit for that to be possible at the moment…

I’ve got JSR223/Jython working fine on Windows 10, OH 2.4 Stable. It will not work on the Windows machine with any more recent version (2.5 Milestones or Snapshots).

Now that I’m back home I am trying to get it working on my main Linux box, and I am having no luck whatsoever. I have tried the most recent snapshot, 2.5 M1 and M2, and 2.4 Stable, and with each of those versions the logs all disappear when I put the JYTHON EXTRA_JAVA_OPTS line in. I have tried adding it to etc/default/openhab2, start.sh and setenv and all three end up the same.

In addition I’m seeing problems in all 2.5 versions where there’s a conflict between GoogleTTS and the RESTDOCS. swagger.json can’t be found or accessed when clicking on the REST UI page. This is a mess! I was really hoping to get going with python rules.

What version of Java did you use on Windows and now in Linux? And have you been following these installation instructions? Myself and others have done this install many, many times without issues on Linux with OH2.4 through the latest snapshots. I’m not saying it’s impossible that there is an issue, but it is much more likely that there is a problem in your configuration.

Are you doing fresh installs or are you upgrading and downgrading? How are you upgrading and are you clearing the cache? In 2.5M2, the RESTDOCS was moved to the UIs.

@5iver, on my Windows Machine I have Java SE 1.8.0_221-b11. On the Linux machine it’s OpenJDK 11.0.4 (2019-07-16). I’m in agreement with you, especially now that my linux install is also having issues, that there’s something I’m doing wrong, or a config problem on my end.

I followed the installation instructions to the letter, as far as I can tell. On windows I believe I’m doing “fresh” installs… I follow the backup/upgrade instructions in the documentation. On Linux I’m just using the command line instructions and installing the package over the old one. (Keeping a backup in case of emergency). Going from 2.4 to 2.5 seems to need some config changes which I go in and update as needed in between installs (the Logging config file changes a bit, switching from mail action to binding, and moving the restdocs from “misc” to “ui”).

Oh, and yes, I do clear the cache and tmp folders every time I go through this.

Openhab requires Java 8 not 11. Hopefully the version 1 addons will be removed from OH3 so it can run on Java 11.

Wow, you know I think I vaguely remember reading that years ago when I first loaded openhab, but after numerous “sudo apt update/upgrade” I guess somehow I ended up with 11. I’ll try to figure out how to revert to 8.

Thanks for the heads up.

This will definitely cause issues. Which Linux distribution are you using?

Are you using the update script? I don’t use a repository installation, but I would think you’d need to upgrade an existing installation rather than installing again over the top of another version. If downgrading the Java does not help, I suggest backing up, uninstalling, and then reinstalling from scratch.

I am using Ubuntu Server 18.04.3 LTS on the Linux box.

No, I am not using the update script, I don’t think I communicated my method very well… I actually use the repository and did a Package Repository Installation to originally install, and then I use the procedure here to upgrade or downgrade and choose the specific build I want, as I’ve done a few times in the last day or two.

However, the main update is that I rolled back from Java 11 to Java 8 using this guide and I’m now in business on JSR233/Jython! It wasn’t exactly seamless when I fired up OpenHAB after switching to Java 8, it took about 3 restarts of OH, and streams and streams of red error logs, but eventually it settled out. And, the RestDocs UI now works as well. There are some things that have stopped working that I need to figure out (seems like executeCommandLine and sendHttpGetRequest might be broken) but I will have to troubleshoot tomorrow.

Thanks for the help thus far though!

2 Likes

Correction to my post above, the RestDocs UI is still broken when GoogleTTS is installed (can’t find swagger.json). And, sound commands like “playSound()” and “say()” are not working, from rules DSL or from Karaf.

However, pretty much everything else seems to be working, false alarm on “executeCommandLine()” and “sendHttpGetRequest()”.

The problem with RestDocs is related to…


These are working for me… and work in Jython too.