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

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.

For future reference, I just ran into this while trying it out (on Windows), and solved it by doing the following:

  1. Don’t copy jython-standalone-2.7.0.jar to conf\automation\jython, copy it to runtime\lib\boot instead
  2. Instead of adding:
    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
    to start.bat, simply add:
    set EXTRA_JAVA_OPTS=-Dpython.home=C:\openhab2\conf\automation\jython -Dpython.path=C:\openhab2\conf\automation\lib\python

Be advised this probably won’t survive an upgrade since the runtime directory gets pretty much overwritten (and you’re not really supposed to touch it much), but for quick testing it does the trick. Hope this helps.

1 Like

Thank you, Yannick! That sounds like a good workaround. You are correct… the update script removes /runtime/ completely, which is why I have not used /runtime/lib/boot/ or /runtime/lib/ext/ in the helper library setup instructions to prevent people having to setup everything again after an update. Well… that and because /runtime/ shouldn’t be messed with. I’m experimenting with a few things to ease the setup of Jython (and Groovy), which will also help out Windows users with this issue. It has just been very slow going using Eclipse for the IDE.

1 Like