OH2.4 stops BasicUI and all other things in the HABPanel during start up

  • Platform information:
    • Hardware: RaspPi2B
    • OS: Raspian Jessy
    • Java Runtime Environment: 1.8.0_151-b12
    • openHAB version: 2.4

Currently I migrate from OH2.1 to OH2.4.
During the “migration phase” I started the OH instance per hand using start.sh script. I get some warnings like missing script files … normally in the boot process, if not all is loaded at that time. BUT OH2.4 runs stable with all of my configured items, things, rules, scripts, …

After that I want to go live and I wanted to start OH using system service file. In this case I get errors from the rule engine, that some items can not resolved or some items can not be casted from null to a number. Each positions which was marked as bad in the log I changed to a null pointer test of the item and the item state. But I get the same error messages too (it seems, that the test was false positive) and OH crash.

Here are some examples:

14:49:39.191 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'HeatingTimes': Could not cast NULL to java.lang.Number; line 31, column 13, length 24

14:50:27.769 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'LightEvents': Could not cast NULL to java.lang.Number; line 75, column 11, length 33

14:50:21.567 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'RegenFenster': The name 'OPEN' cannot be resolved to an item or type; line 52, column 33, length 4

A little bit after that

14:50:58.993 [INFO ] [.basic.internal.servlet.WebAppServlet] - Stopped Basic UI
14:51:06.225 [DEBUG] [.eclipse.smarthome.model.rule.runtime] - BundleEvent STOPPING - org.eclipse.smarthome.model.rule.runtime

And many of this

14:51:14.790 [WARN ] [ommon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.NullPointerException: null
        at org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl.lambda$2(RuleEngineImpl.java:336) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]

For example, the error message above in LightEvents Line 75 comes from here:

Line74: if (LightningOnHourWE !== null && LightningOnHourWE.state !== null) {
Line75:  onWE = (LightningOnHourWE.state as Number)
Line76: }

Did anyone have an idea why OH does not start as service but runs fine started by hand?

14:49:39.191 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'HeatingTimes': Could not cast NULL to java.lang.Number; line 31, column 13, length 24

This line indicates that you have an Item that is NULL that you assume that it has a Number state. Are you using restoreOnStartup using MapDB or rrd4j? Did you include those in your migration? Regardless, you should check whether an Item is NULL or UNDEF before blindly trying to use it or cast it to a number or the like in your Rules.

14:50:21.567 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'RegenFenster': The name 'OPEN' cannot be resolved to an item or type; line 52, column 33, length 4

This one is an indication that you are experiencing the long standing problem with Rules starting to execute before OH is ready for them to start executing. Usually a restart of OH will resolve the problem. If not, there are lots of approaches to avoid the problem, usually involved with moving the .rules files outside of rules folder until OH has started up and then moving them back. openHABian has a script that does this automatically.

This has been a problem forever so you probably just got lucky you haven’t seen this before.

This is not a problem with the Next Gen Rule Engine.

I cannot explain why OH closes down after that though. Those errors would not cause OH to crash or close. And if you are seeing those logs, something is asking OH to close nicely.

These might be safe to ignore. This looks like you have some Timers that exploded, probably because of the previous errors. Solve those earlier errors first and then worry about these if they persist.

That’s not how you avoid the NULL errors. This is:

if(LightingOnHourWE.state != NULL && LightingOnHourWE.state != UNDEF) {

I can’t explain why it runs by hand and not as a service.

Finally, OH 2.4 was released 11 months ago and OH 2.5 is scheduled to be released in 11 days. Givne your upgrade path seems to be only once every two-three years, I strongly recommend upgrading to 2.5.

In fact, what I would recommend doing is take a spare SD card and configure openHABian on that card. Then migrate your config and data from your old OH instance to the new SD card. I can’t remember if there was an openhab-cli on 2.1. If there was you can run sudo openhab-cli backup toback up your 2.1 config, copy over zip to the new SD card, then run restore.

If not, you need to copy all of $OH_CONF and all of $OH_USERDATA except for cache and temp.

Thanks for your hints

  1. I use restoreOnStartup with mysql persistence service and I include this in my migration
  2. I check EACH Item for NULL or UNDEF, before I use it as a number
  3. I changed all of my NullPtr test to your solution (?.state != NULL && .state != UNDEF)

Nothing helps. I have no errors or warnings during start up, but the basic ui is closed.
Tommorrow I will try to test OH2.5.0.M6

The cause of the problem is not related to your Rules than (which I suspected). Something else is going on. I couldn’t say what that is not knowing exactly how you’ve installed it and are running it.