Modbus transformation OH 3.4.4 java 17


After updating to debian12 (java17) the modbus JS transformations no longer work. I get the following error:

2023-07-16 18:45:20.292 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler@5eb42a50': Cannot invoke "javax.script.Compilable.compile(" because "engine" is null
java.lang.NullPointerException: Cannot invoke "javax.script.Compilable.compile(" because "engine" is null
	at org.openhab.transform.javascript.internal.JavaScriptEngineManager.getCompiledScriptByFilename( ~[?:?]
	at org.openhab.transform.javascript.internal.JavaScriptTransformationService.transform( ~[?:?]
	at org.openhab.binding.modbus.internal.SingleValueTransformation.transform( ~[?:?]
	at org.openhab.binding.modbus.internal.CascadedValueTransformationImpl.transform( ~[?:?]
	at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.transformCommandAndProcessJSON( ~[?:?]
	at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.handleCommand( ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor135.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke( ~[?:?]
	at java.lang.reflect.Method.invoke( ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect( [bundleFile:?]
	at org.openhab.core.internal.common.InvocationHandlerSync.invoke( [bundleFile:?]
	at jdk.proxy1756.$Proxy1906.handleCommand(Unknown Source) [?:?]
	at org.openhab.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand( [bundleFile:?]
	at org.openhab.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem( [bundleFile:?]
	at jdk.internal.reflect.GeneratedMethodAccessor134.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke( ~[?:?]
	at java.lang.reflect.Method.invoke( ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect( [bundleFile:?]
	at [bundleFile:?]
	at [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]
	at java.util.concurrent.ThreadPoolExecutor$ [?:?]
	at [?:?]

yaml .thing

UID: modbus:data:voletSalonCoteCuisine
label: Volet salon coté cuisine (Modbus Data)
thingTypeUID: modbus:data
  readValueType: int16
  readTransform: JS:modbus_rollershutter_read.js
  writeTransform: JS:modbus_rollershutter_write.js
  writeType: holding
  readStart: "3"
  updateUnchangedValuesEveryMillis: 5000
  writeValueType: int16
  writeMultipleEvenWithSingleRegisterOrCoil: false
  writeMaxTries: 3
  writeStart: "3"
bridgeUID: modbus:poller:VoletsRezModubusSerialSlave:VoletsRezRegularPollHreg

How can I solve the problem?

For openHAB 3.x.x you have to downgrade to Java 11 ! Java 17 is not supported for that versions.

Or upgrade to OH4.

I’ve set java 11 as the default interpreter (by “update-java-alternatives”)

Note that on my machine it was already installed but it is not available on debian 12.

I suggest putting a warning when you try to launch open hab with the wrong version of java (I saw nothing in the log)

Tanks !

The OH3.3 code is years old and superseded by newer versions. It’s not maintained any longer so we cannot retroactively change that code.
Sorry but just like with any other software, you have to ensure yourself you meet the prerequisites w.r.t. HW, OS and middleware when you install or upgrade your box.

1 Like

oops typo error, 3.4.4 sorry. I’ll change the title if I can

Ok,but it does not make a difference if 3.3 or latest. Users remain responsible to ensure OH prerequisites are met before they change their system, and if they do properly and act with proper precaution, there’s no need to change OH code.
To upgrade a working system to a new base OS release as soon as that’s out (bookworm was only one month old) isn’t clever.
I would not call that prudent and would not want to help with or encourage other people to do the same.

I upgraded (with a new fresh sd card) to last update, but I have same issue, I imported my full backup:

java.lang.NullPointerException: Cannot invoke "javax.script.Compilable.compile(" because "engine" is null

last update e java -version

openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb11u1, mixed mode, sharing)

in my sitemap I have a frame with this item:

Number:Angle              weather_direction_wind       "Direzione vento [JS(windDir.js):%s]"	<Wind>        (gOutdoor) ["Measurement", "Wind"]         { channel="fineoffsetweatherstation:gateway:bea74dd829:direction-wind" }

and he page isn’t loaded with that Exception

Either run 3.4 with Java 11 or 4.0 with Java 17.

I’m running 4.0.1 with Java17 (Fresh installation on a new SD card and imported all the backup with openhab-cli --full backup)

Did you run the upgrade tool after import ?

Actually, because I have many and many bindings and item, rules and transformation script I did as follow:

  • openhab-cli --full backup
  • Installed in a fresh sd card to last openhabian 4.0.1 (keeping the 3.4.4)
  • openhab-cli restore

Did I miss something?

Just to understand you right:
Fresh install of openHABian 1.8 (there is no 4.x) image
Installed openHAB 4.0x
Restored backup

If thats your steps, you missed the upgrade tool converting your configs from 3.x to 4.x

yes sorry the v1.8 with 4.0.1 openhab, is there a tutorial for the update to from 3 to 4?

Yes there is, just can‘t find it while not at home.
Juste search for „upgrade-tool“.

1 Like

May be you are referring to this post

Perhaps the issue is the same as this OH4 transformationService of type 'JS' is unavailable