OpenHAB 4 FrameworkEvent ERROR Java 17

This how to OpenHAB 4 FrameworkEvent ERROR Java 17 helps to deal with this error. In this case it is related to Java 17.

OpenHAB FrameworkEvent ERROR

OpenHAB FrameworkEvent ERROR

 

Index Of How To OpenHAB 4 FrameworkEvent ERROR Java 17

Background of OpenHAB 4 FrameworkEvent ERROR Java 17

You might face after upgrading your OpenHAB instance or after upgrading some other software a Framework Error that shows up in your log file. In my case, the framework error was related to Java. In case this information is needed or helpful for you, i am running OpenHAB 4 on a Raspberry Pi 4. The full error message looks like this:

[ERROR] [Events.Framework                    ] - FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.io.homekit [266]
  Unresolved requirement: Import-Package: org.openhab.core.common
    -> Export-Package: org.openhab.core.common; bundle-symbolic-name="org.openhab.core"; bundle-version="4.0.3"; version="4.0.3"
       org.openhab.core [150]
         Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=17))"
  Unresolved requirement: Import-Package: org.openhab.core.common.registry
    -> Export-Package: org.openhab.core.common.registry; bundle-symbolic-name="org.openhab.core"; bundle-version="4.0.3"; version="4.0.3"; uses:="org.openhab.core.events,org.openhab.core.service,org.openhab.core.storage,org.osgi.framework,org.slf4j"
    at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1847) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1840) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1783) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1745) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1667) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234) ~[org.eclipse.osgi-3.18.0.jar:?]
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345) ~[org.eclipse.osgi-3.18.0.jar:?]

 

How To Fix OpenHAB 4 FrameworkEvent ERROR Java 17

In my case, the above error message was related to the wrong Java version. This because OpenHAB 4 leverages on Java 17, which is the newest version. However, after installing another piece of software, which is leveraging on a previous Java version, the systems standard moved to Java 11. 

Therefore, to check the current active Java version, fire the below command:

sudo update-alternatives --config java

This gives you most likely something like the below. It says clearly, that my system by default is using  Java 11.

openhabian@OpenHAB:/usr/lib/unifi $ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-17-openjdk-armhf/bin/java      1711      auto mode
* 1            /usr/lib/jvm/java-11-openjdk-armhf/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-17-openjdk-armhf/bin/java      1711      manual mode
  3            /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number:

How to change it? Well, this is actually simple and the menu tells you. In the above case, and to use Java 17, i simply had to enter “0”. Following enter 0 the Java version changed to Java 17. 

After changing, i rebooted the system to be on the safe side and entered after reboot again:

sudo update-alternatives --config java

This time, the system printed the below on the screen:

openhabian@OpenHAB: $ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-17-openjdk-armhf/bin/java      1711      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-17-openjdk-armhf/bin/java      1711      manual mode
  3            /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number:

This is exactly what i needed. And yes, after the reboot and this fix, OpenHAB did work properly.

Additional Information

Follow me

It would be amazing if you follow my myhowto.blog. To my blog is actually easy! You can leverage on

  • Click to follow me on Twitter
  • Bookmark this page and comeback from time to time

Help and Comments

I am really looking forward for you to contact me if for example you found a better option or other idea then in this how to. Also, please touch base if you found an error or anything not working or if you have something that you would love to be added to the myhowto.blog. Simply click this link to touch base with me.

Linking Or Recommending The How To Or The myhowto.blog

I would love to see you are recommending this how to or link it to your website. Also, I would love if you link or recommend the whole myhowto.blog. Please feel free to do so! In case you like to touch base regarding this topic with me, then simply click this link. I look forward!