Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for running openHAB with Java 11 #768

Closed
wborn opened this issue Sep 17, 2018 · 26 comments
Closed

Add support for running openHAB with Java 11 #768

wborn opened this issue Sep 17, 2018 · 26 comments

Comments

@wborn
Copy link
Member

wborn commented Sep 17, 2018

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
Copy link
Member Author

wborn commented Sep 25, 2018

Today Java 11 got released! 🎁 😀

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

@BClark09
Copy link
Member

BClark09 commented Sep 26, 2018

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
Copy link
Member Author

wborn commented Sep 26, 2018

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.

@BClark09
Copy link
Member

BClark09 commented Sep 28, 2018

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
Copy link
Member Author

wborn commented Dec 13, 2018

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.

@BClark09
Copy link
Member

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
Copy link
Member Author

wborn commented Feb 22, 2019

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

@dbadia
Copy link

dbadia commented Apr 12, 2019

@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
Copy link
Member Author

wborn commented Apr 12, 2019

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
Copy link
Member

J-N-K commented Apr 12, 2019

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

@wborn
Copy link
Member Author

wborn commented Apr 12, 2019

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

@dbadia
Copy link

dbadia commented Apr 15, 2019

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

@davidgraeff
Copy link
Member

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
Copy link
Member Author

wborn commented May 5, 2019

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 . 😉

@mheidt
Copy link

mheidt commented Aug 18, 2019

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 added a commit to wborn/openhab-distro that referenced this issue Nov 1, 2019
Updates the path used with the patch-module options to fix the following warning on Java 9+:

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

Adds a few more "add-opens" to the Karaf scripts so we can suppress the warnings on Java 9+ caused by XStream's reflection usage.
Because XStream still works without any issues on Java 11 there is no need for users to see these warnings:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/openhab/userdata/cache/org.eclipse.osgi/66/0/bundleFile) to field java.lang.reflect.Proxy.h
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
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

Related to openhab#768

Signed-off-by: Wouter Born <[email protected]>
@wborn
Copy link
Member Author

wborn commented Nov 1, 2019

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
Copy link
Member Author

wborn commented Nov 1, 2019

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

kaikreuzer pushed a commit that referenced this issue Nov 1, 2019
Updates the path used with the patch-module options to fix the following warning on Java 9+:

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

Adds a few more "add-opens" to the Karaf scripts so we can suppress the warnings on Java 9+ caused by XStream's reflection usage.
Because XStream still works without any issues on Java 11 there is no need for users to see these warnings:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/openhab/userdata/cache/org.eclipse.osgi/66/0/bundleFile) to field java.lang.reflect.Proxy.h
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
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

Related to #768

Signed-off-by: Wouter Born <[email protected]>
wborn added a commit to wborn/openhab-distro that referenced this issue Nov 11, 2019
Suppresses the following warnings when using Basic UI on Java 9+

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.gson.internal.bind.ReflectiveTypeAdapterFactory (file:/openhab/userdata/cache/org.eclipse.osgi/20/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

Related to openhab#768

Signed-off-by: Wouter Born <[email protected]>
kaikreuzer pushed a commit that referenced this issue Nov 12, 2019
Suppresses the following warnings when using Basic UI on Java 9+

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.gson.internal.bind.ReflectiveTypeAdapterFactory (file:/openhab/userdata/cache/org.eclipse.osgi/20/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

Related to #768

Signed-off-by: Wouter Born <[email protected]>
@wborn
Copy link
Member Author

wborn commented Nov 24, 2019

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

@wborn
Copy link
Member Author

wborn commented Dec 1, 2019

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. 🙂

@kaikreuzer
Copy link
Member

I think this can be closed now - 3.0 is on Java 11 🎉.

@tgurr
Copy link

tgurr commented Jan 27, 2020

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.

@kaikreuzer kaikreuzer unpinned this issue Jan 27, 2020
@kaikreuzer
Copy link
Member

Thanks for noticing, good point!

@ChrisDumont
Copy link

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
Copy link
Member Author

wborn commented Mar 1, 2020

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
Copy link
Contributor

5iver commented Mar 1, 2020

incompatibilities with Jython

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

@J-N-K
Copy link
Member

J-N-K commented Mar 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants