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

This is my startup.bat file:

I have added the same to sh.bat as my Openhab runs as a service.
I can add as an windows enviroment variable instead.
I have tried it before but there was no difference but it was before I have changed the loacation of Jython standalone file. Sorry I have tried many variation and that’s why I ask some help. So I welcome any suggestion as I think I have a tiny bug somwhere. OH was restared after each change. If you suggest I can do it more time.

I just looked at your log and Jython is starting. What do you have under C:\openhab2\conf\automation\lib\python? Did you setup your configuration.py?

Here is the path and the content:

That looks good. I think it has something to do with your EXTRA_JAVA_OPTS or permissions. What happens if you start OH manually?

This is the Karaf Console:

log files of openahb.log and ruleengine.log:
ruleengine_201911061945.log (36.4 KB)
It does not load any rules from automation folders just when I copy it there while Openhab runs. Result is the same:
2019-11-03 19:46:48.702 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language ‘py’ with identifier: file:/C:/openhab2/conf/automation/jsr223/python/personal/owm_daily_forecast.py

2019-11-03 19:46:48.983 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script ‘file:/C:/openhab2/conf/automation/jsr223/python/personal/owm_daily_forecast.py’: ImportError: No module named core in at line number 104

I also encounter the same problem as https://community.openhab.org/u/kovacsi2899 (Windows 10, last SNAPSHOT, Jython, Openhab runs as a service, …)
Thanks in advance

So I have installed 2.5R1. Than I set up according to helper instructions. I have checked setnev.bat and config is ok so I suppose to use this in start.bat: 1. 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
however it does not work, so I used this workaround: [Windows] All OH logs stop when Jython is in the classpath

but than when any Phyton or Jythone rules are starting none of the libraries are loaded. I get such error messages: Error during evaluation of script ‘file:/C:/openHAB2/conf/automation/jsr223/python/personal/hello_world.py’: ImportError: No module named core in at line number 5
line 5:

Put this in a script and post the result…

import sys
from org.slf4j import Logger, LoggerFactory

LOG = LoggerFactory.getLogger("jsr223.jython.TEST")
LOG.warn("sys.path = {}".format(sys.path))

It sounds to me like your python.path may not be set. It would also be interesting to have you test the bundle…

2019-12-21 19:13:46.349 [WARN ] [jsr223.jython.TEST ] - sys.path = [‘C:\openhab2\runtime\lib\boot\Lib’, ‘C:\openhab2\runtime\lib\boot\jython-standalone-2.7.0.jar\Lib’, ‘classpath’, ‘pyclasspath/’]

Yep… your missing $OPENHAB_CONF/automation/lib/python. Something is wrong with your EXTRA_JAVA_OPTS or setenv.bat.

start.txt (223 Bytes) setenv.txt (7.0 KB)

I forget… is that top section user or system? Set it in the system variables so that your service can use them. Or set the runAs for the service as an actual account, then log in as that user and set their user variables. Much easier to do this in the start.bat. And even easier to use the bundle!

Openhab runs as a service on my server.
Same result: 2019-12-21 20:21:56.358 [WARN ] [jsr223.jython.TEST ] - sys.path = [‘C:\openhab2\runtime\lib\boot\Lib’, ‘C:\openhab2\runtime\lib\boot\jython-standalone-2.7.0.jar\Lib’, ‘classpath’, ‘pyclasspath/’]

I will put it into start.bat as well in openhab/ folder and restart again

No change: 2019-12-21 20:34:53.006 [WARN ] [jsr223.jython.TEST ] - sys.path = [‘C:\openhab2\runtime\lib\boot\Lib’, ‘C:\openhab2\runtime\lib\boot\jython-standalone-2.7.0.jar\Lib’, ‘classpath’, ‘pyclasspath/’]

is it better?
2019-12-21 21:07:56.654 [WARN ] [jsr223.jython.TEST ] - sys.path = [‘C:\openhab2\conf\automation\lib\python’, ‘C:\openhab2\conf\automation\jython\Lib’, ‘C:\openhab2\runtime\lib\boot\jython-standalone-2.7.0.jar\Lib’, ‘classpath’, ‘pyclasspath/’]

Now it seems that it works:

Here is the enviroment variable what I use now:

Yes, that looks to be working now. I also shifted over to a Windows environment. Setting up the EXTRA_JAVA_OPTS in start.bat worked fine. Remember the bug with scripts not starting in Windows (linked somewhere above). Powershell is also terrible for tailing!

I would think that the solution is very simple. I set everything back (deleted jython standalone from lib/boot folder, deleted all extra_java_opts lines from start.bat, setnev.bat etc) to default and I have changed only one thing:

I put into enviroment variable JAVA_TOOL_OPTIONS instead of EXTRA_JAVA_OPTS and it works immediatelly.

so in case of windows I would change description of installation here: https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html

Also there is one thing what is not 100% clear for me. Whitch start.bat we have to modify? There is one in main openhab2 folder and another one in \openhab2\runtime\bin folder. It should be also specified.

The instructions in the helper library documentation works well for setting up openHAB in Windows when it is not being setup as a service. It is a better solution than modifying environment variables.

I took some time this evening to read the documentation on setting up openHAB to run as a service on Windows. At step 4, include the following in the Java Parameters section in the openHAB2-wrapper.conf…


I will update the helper library documentation with this information. However, these steps are no longer needed if you use the test Jython bundle or after it is merged.

The helper library documentation is referring to $OPENHAB_HOME\start.bat.

1 Like

In all of the testing I have done today in Windows, I have not seen an issue with the logs not working. I’ve been using S1778 and watching the log in Powershell with…

Get-Content C:\openhab-1778\userdata\logs\openhab.log -Wait

Sometimes this will stutter, but CTL-C got it caught up.

Thanks! I was not clear from the description as well that this is manual startup or manual config. I mean windows setup is a manual config or at least when I started to use OH it was. After that automated update was avaiable sometime but it never worked for me. Anyway I have modified my wrapper.con, added these 3 lines, deleted enviroment variables, cleared catch and tmp folders and restarted everything all over again. It works. So I would suggest to clarify these differences a little bit more detailed in the helper instructions than it will be perfect.

1 Like