openhab/openhab-distro

Add support for running openHAB with Java 11

Closed this issue ยท 26 comments

wborn commented

Currently openHAB only supports Java 8 which is the most recent long-term support (LTS) release of Java.
We should also add support for running openHAB with Java 11, which is the next LTS release and will be released in a week (September 25th, 2018).

In #761 Karaf was upgraded to 4.2.1 which supports Java 8, 9, 10 and 11.

After testing openHAB with Karaf 4.2.1 on Java, 9, 10 and the JDK 11 Early-Access Builds the following issues have been found so far:

For compatibility of Eclipse SmartHome with Java 11 see also Test ESH with Java 9/10/11.


To simplify JDK 11 testing, I've created an openhab-docker branch that makes Travis create Debian and Alpine amd64 Docker images using Zulu Java 11 every day.

For the available tags see my wborn/openhab-jdk11 Docker Hub repository.

wborn commented

Today Java 11 got released! ๐ŸŽ ๐Ÿ˜€

Azul still offers early access (EA) downloads. They do have a nice Java 11 blog.

Debian Buster contains a armhf package of openJDK 11, so will use that to help test on the RPi if you need! :)

pi@server:~ $ java --version
openjdk 11 2018-09-25
OpenJDK Runtime Environment (build 11+28-Debian-1)
OpenJDK Server VM (build 11+28-Debian-1, mixed mode)
wborn commented

so will use that to help test on the RPi if you need!

All Java 11 testing is appreciated. :-) Do you know if they compile OpenJDK 11 with hardware floating point operations instead of software floating point operations? AFAIK that usually is the main performance issue with OpenJDK 8 on Raspbian.

I don't know unfortunately. I'm assuming that since the difference between:

~$ java --version
openjdk 11 2018-09-25
OpenJDK Runtime Environment (build 11+28-Debian-1)
OpenJDK Server VM (build 11+28-Debian-1, mixed mode)

~$ java -XshowSettings 2>&1 | grep sun.arch
   sun.arch.abi = 
   sun.arch.data.model = 32

and

~ $ java -version
openjdk version "1.8.0_152"
OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, mixed mode, Evaluation)

~ $  java -XshowSettings 2>&1 | grep sun.arch
    sun.arch.abi = gnueabihf
    sun.arch.data.model = 32

means that OpenJDK-11 isn't set up for hardware float by default? Can this be changed simply by setting this property?

wborn commented

On Windows the nrjavaserial library crashes the whole runtime when used with Java 11.

See also NeuronRobotics/nrjavaserial#131 and this hs_err_pid3924.log.

Looks like getting Jython running has a difference in behaviour on JDK11 too:

https://community.openhab.org/t/solved-setting-java-extra-opts-for-jython-changes-logging-location/65531

wborn commented

Nowadays the Java 11 Zulu JVMs can be downloaded for most platforms:

@wborn Regarding

On Windows the nrjavaserial library crashes the whole runtime when used with Java 11.

I have a patched version (per NeuronRobotics/nrjavaserial#131) of nrjavaserial-3.14.0.jar which has resolve the issue for me. Should I submit a PR somewhere?

All of my prior work has been on the addons so I'm not sure which OH git project the core jars are in. On my OH runtime, the library is under runtime/system/com/neuronrobotics/nrjavaserial/3.14.0/nrjavaserial-3.14.0.jar

wborn commented

I'd prefer all PRs for adding Java 11 support to go to the upstream repository (NeuronRobotics/nrjavaserial). If you read the issue (NeuronRobotics/nrjavaserial#131) they have the java11 branch for this.

J-N-K commented

Unfortunately it looks that there is not much progress over there.

wborn commented

That's what's also being said about openHAB. ;-)

Found an issue with Eclipse IDE and Java 11. I am running Java 11 on my production system (linux) without issue. UIs work fine.

In my development environment on Windows/Eclipse, PaperUI works in Java 9 and 10, but not in Java 11 or 12. When running with Java 11 or 12, I get a 404 error on http://localhost:8080/start/index

If change the runtime JRE in openHAB_Runtime back to 9 and restart, PaperUI is fully functional again.

Again, this seems specific to Eclipse and/or Windows as my prod setup with JRE 11 on linux works fine.

Anyone else see this issue?
I can dig deeper but wanted to start by seeing if this is already being tracked

EDIT:
Updated my description above to indicate that no UIs work (as opposed to just BasicUI or PaperUI).
Inspecting the logs with Java 11, I see tons of module resolution errors like this:

!ENTRY com.eclipsesource.jaxrs.jersey-min 4 0 2019-04-15 19:35:42.382
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: com.eclipsesource.jaxrs.jersey-min [9]
  Unresolved requirement: Import-Package: javax.activation

Full log:
new11fail.txt

Unfortunately com.eclipsesource.jaxrs is 4 years old and out of maintenance and the bundled jersey is also as old. That is probably not Java 11 compatible.

I'm on my way to replace the entire dependency with the current OSGi approach that doesn't even need a specific library, just the reference implementation. See openhab-core for more information and stay tuned.

wborn commented

According to your logging it also fails to allocate a port @dbadia which may also be causing issues :

2019-04-15 19:35:43.190:WARN:oejobis.JettyServerServiceTracker:Start Level: Equinox Container: 1697a2ab-c73a-4746-bb4e-e63903216ca7: 
MultiException[java.net.BindException: Address already in use: bind, java.net.BindException: Address already in use: bind]

It looks we might run into SSE issues with the old Jersey version, see also eclipse-ee4j/jersey#3965 (comment). It's easier to stay tuned if you add links (openhab/openhab-core#739) @davidgraeff . ๐Ÿ˜‰

I am using the latest buster rpi noobs image and installed a 2.5 snapshot.
But OpenHAB doesn't start up:

WARNING: package org.apache.karaf.specs.locator not in java.base
Error starting karaf activator org.apache.karaf.specs.activator.Activator:org/apache/karaf/specs/locator/OsgiLocator

openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-post-Raspbian-5)
OpenJDK Server VM (build 11.0.3+7-post-Raspbian-5, mixed mode)

wborn commented

WARNING: package org.apache.karaf.specs.locator not in java.base
Error starting karaf activator org.apache.karaf.specs.activator.Activator:org/apache/karaf/specs/locator/OsgiLocator

I also ran into it and it's fixed for me with the changes in #991 @mheidt .

wborn commented

It seems Gson is also causing warnings due to reflection when opening a sitemap in Basic UI:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.gson.internal.bind.ReflectiveTypeAdapterFactory (file:/home/wouter/software/openhab/instance/userdata/cache/org.eclipse.osgi/21/0/bundleFile) to field java.io.ByteArrayOutputStream.buf
WARNING: Please consider reporting this to the maintainers of com.google.gson.internal.bind.ReflectiveTypeAdapterFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
wborn commented

Hey @dbadia the UIs work for me in Eclipse with the changes in #1007.

wborn commented

It seems that older MaryTTS versions do work with GA Java 11 releases. In GA releases the java.version consists of 3 segments instead of one, i.e. "11.0.5" instead of "11" that was used in the Early Access releases. So I've closed the MaryTTS issues. ๐Ÿ™‚

I think this can be closed now - 3.0 is on Java 11 ๐ŸŽ‰.

tgurr commented

Still shows up as "Pinned issues" on the openhab-distro repository, might want to remove that as well now if not kept on purpose there.

Thanks for noticing, good point!

I'd like some clarification, please. So, 3.0 runs with Java 11. That's good news. But according to the "Installation Overview" openhab2 needs Java 8. I'd like to upgrade my server to Debian Buster which only comes with Java 11. I can, if need be, install openjdk-8-jre from oldstable (Stretch) but I like to avoid mixing OS versions on my servers.

Is there an intention/plan to make openhab2 run with Java 11?

wborn commented

Instead of mixing OS versions you can also install the Zulu Java 8 JVM. We do the same with the Debian Buster based openHABian and Docker containers.

There was already a lot of work done to make OH 2.5 compatible with Java 11 so you can try it yourself to see how well it works. I've done some testing with it and the only major issues that I know of are incompatibilities with Jython and the whole JVM crashing on Windows when using add-ons that access serial devices.

When there are add-on specific Java 11 issues it may be possible to fix these in 2.5.x.

5iver commented

incompatibilities with Jython

Which may be resolved in Jython 2.7.2b3 (I have not tested it with Java 11)

J-N-K commented

It will NOT run under Java11 out-of-the-Box. The boot classpath method of adding jython is not working.