Modbus transformation OH 3.4.4 java 17

Hello

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(java.io.Reader)" because "engine" is null
java.lang.NullPointerException: Cannot invoke "javax.script.Compilable.compile(java.io.Reader)" because "engine" is null
	at org.openhab.transform.javascript.internal.JavaScriptEngineManager.getCompiledScriptByFilename(JavaScriptEngineManager.java:77) ~[?:?]
	at org.openhab.transform.javascript.internal.JavaScriptTransformationService.transform(JavaScriptTransformationService.java:119) ~[?:?]
	at org.openhab.binding.modbus.internal.SingleValueTransformation.transform(SingleValueTransformation.java:140) ~[?:?]
	at org.openhab.binding.modbus.internal.CascadedValueTransformationImpl.transform(CascadedValueTransformationImpl.java:51) ~[?:?]
	at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.transformCommandAndProcessJSON(ModbusDataThingHandler.java:249) ~[?:?]
	at org.openhab.binding.modbus.internal.handler.ModbusDataThingHandler.handleCommand(ModbusDataThingHandler.java:197) ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor135.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
	at org.openhab.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
	at jdk.proxy1756.$Proxy1906.handleCommand(Unknown Source) [?:?]
	at org.openhab.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:85) [bundleFile:?]
	at org.openhab.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) [bundleFile:?]
	at jdk.internal.reflect.GeneratedMethodAccessor134.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:833) [?:?]

yaml .thing

UID: modbus:data:voletSalonCoteCuisine
label: Volet salon cotƩ cuisine (Modbus Data)
thingTypeUID: modbus:data
configuration:
  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.

Hello,
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(java.io.Reader)" 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