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

A java problem with make posix jmavsim in Ubuntu #9557

Closed
Hs293Go opened this issue May 28, 2018 · 22 comments
Closed

A java problem with make posix jmavsim in Ubuntu #9557

Hs293Go opened this issue May 28, 2018 · 22 comments

Comments

@Hs293Go
Copy link

Hs293Go commented May 28, 2018

Hello everybody, I hit a snag with jmavsim SITL simulation on ubuntu but I tried to strictly follow instructions. I run Ubuntu 18.04 (Bionic), gazebo 9 and ROS Melodic. Firmware and submodules are up to date.

My problem is that make posix jmavsim results in an error as shown below.

BUILD SUCCESSFUL
Total time: 0 seconds
Exception in thread "main" java.lang.NoClassDefFoundError: javax/vecmath/Tuple3d
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:374)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: javax.vecmath.Tuple3d
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 3 more
Exception in thread "main" java.lang.NoClassDefFoundError: javax/vecmath/Tuple3d
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:374)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: java.lang.ClassNotFoundException: javax.vecmath.Tuple3d
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 3 more

I believe this is not a new issue, as it appeared to be almost identical to #9311, with the exception that I use ubuntu. My Java version is

openjdk version "10.0.1" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)

Per @julianoes 's suggestion, switching to Java 8 (either java-8-openjdk-amd64 or java-8-oracle) and redoing the build resulted in the following:

BUILD SUCCESSFUL
Total time: 1 second
Exception in thread "main" java.lang.UnsupportedClassVersionError: me/drton/jmavsim/Simulator has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Exception in thread "main" java.lang.UnsupportedClassVersionError: me/drton/jmavsim/Simulator has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)

Strangely enough, gazebo setup is largely successful and I am able to simulate in both SITL and HITL. Nevertheless I could really use jmavsim as a lighter, faster simulator since I am only concerned with multirotors. Thank you for looking into this issue!

@hamishwillee
Copy link
Contributor

hamishwillee commented May 29, 2018

We really only test stuff on Ubuntu 16.04 and we have only tested regularly ROS Kinetic.
We will move up to 18.04 sometime soon though (docker script in being looked at).

  1. For ROS we use this script (Kinetic) https://dev.px4.io/en/setup/dev_env_linux.html#gazebo-with-ros
  2. Are you on a real computer or on a VM?

I work primarily on a Ubuntu VM in Windows and have historically been using jMAVSim for quick tests. Unfortunately this no longer works in the VM, so I feel your pain. That said, I have found Gazebo running headless to be similarly performant to jMAVSim (slower to build first time, but about the same when running). To do this you basically prefix your make command with HEADLESS=1 make ...

@TSC21 Has work been done to validate/test PX4 and MAVRos with ROS Melodic?

@Hs293Go
Copy link
Author

Hs293Go commented May 29, 2018

I am using a real computer, and ROS is less of a problem: I do appreciate the delicate link between ros and ubuntu distros, so I rely on another computer running ubuntu 16.04 and Kinetic for ros.

The trouble with jmavsim is that I can't isolate the issue. Is it a problem with java? Incompatible ubuntu distro? I'd greatly appreciate some advice to point me in the direction of a diagnosis.

@hamishwillee
Copy link
Contributor

The second error looks like you have a mismatched JDK and JRE - ie you're running jMAVSIM compiled using a JDK later than 8. Did you do a clean build before trying?

Other than that I don't know. Julian's suggestion of Java 8 is what we use in our docker environments, and I think is the likely pain point.

I'd love this fixed but jMAVSim problems aren't IMO treated as high priority as say Gazebo ones. So if you can work with Gazebo headless that would be smart.

@julianoes
Copy link
Contributor

Per @julianoes 's suggestion, switching to Java 8 (either java-8-openjdk-amd64 or java-8-oracle) and redoing the build resulted in the following:

When you switched to java 8? Did you make sure java --version (or java -version) shows 8? And did you make sure to delete all of out/ before re-building?

@Hs293Go
Copy link
Author

Hs293Go commented May 29, 2018

I proceeded with deleting all of out/ and rebuilded. 'java --version' shows the following

openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

Build is not successful and shows the following

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper
at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:807)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:886)
at java.awt.Window.getToolkit(Window.java:1358)
at java.awt.Window.init(Window.java:506)
at java.awt.Window.(Window.java:537)
at java.awt.Frame.(Frame.java:420)
at java.awt.Frame.(Frame.java:385)
at javax.swing.JFrame.(JFrame.java:189)
at me.drton.jmavsim.Visualizer3D.(Visualizer3D.java:104)
at me.drton.jmavsim.Simulator.(Simulator.java:157)
at me.drton.jmavsim.Simulator.main(Simulator.java:678)
... 5 more
Options parsed, starting Sim.
Starting GUI...
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper
at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:807)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:886)
at java.awt.Window.getToolkit(Window.java:1358)
at java.awt.Window.init(Window.java:506)
at java.awt.Window.(Window.java:537)
at java.awt.Frame.(Frame.java:420)
at java.awt.Frame.(Frame.java:385)
at javax.swing.JFrame.(JFrame.java:189)
at me.drton.jmavsim.Visualizer3D.(Visualizer3D.java:104)
at me.drton.jmavsim.Simulator.(Simulator.java:157)
at me.drton.jmavsim.Simulator.main(Simulator.java:678)
... 5 more

Is using openjdk instead of oracle java likely to cause this issue? I might not be able to rebuild with oracle-8-java just yet because of some minor problems.

@hamishwillee
Copy link
Contributor

hamishwillee commented May 29, 2018

Is using openjdk instead of oracle java likely to cause this issue? I might not be able to rebuild with oracle-8-java just yet because of some minor problems.

No, we use open jdk in our docker setup.

@TSC21
Copy link
Member

TSC21 commented May 29, 2018

@TSC21 Has work been done to validate/test PX4 and MAVRos with ROS Melodic?

MAVROS is already available for ROS Melodic.

@hamishwillee
Copy link
Contributor

hamishwillee commented May 30, 2018

@TSC21 Thanks! Is it time to update our docs/install scripts etc to target ROS Melodic (instead of Kinetic) - or is there a need for both/it is too early?

Or to put it another way, what should be the trigger for me to do this?

@Hs293Go
Copy link
Author

Hs293Go commented May 30, 2018

Okay, the problem is solved by using the following version of java.

java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Build succeeded and jmavsim is up and running. One question remaining: Why does Oracle java succeed while Openjdk fail?

@Hs293Go Hs293Go closed this as completed May 30, 2018
@julianoes julianoes reopened this May 30, 2018
@Paschy11
Copy link

Hi i got the same error and i have these versions of java
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.17.10.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
....
How did you solve that?

@julianoes
Copy link
Contributor

@Paschy11 it looks like you need to use Oracle Java and not OpenJDK.

@Paschy11
Copy link

I'm using Oracle java right now and i have these:
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
exactly the same ones Hs293Go succeeded with. Even if i'm using this version of Java Runtime i'm having this error when i try to launch "make posix jmavsim" after cancelling everything in the out folder:
Exception in thread "main" java.lang.UnsupportedClassVersionError: me/drton/jmavsim/Simulator has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Exception in thread "main" java.lang.UnsupportedClassVersionError: me/drton/jmavsim/Simulator has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Any Ideas?

@Hs293Go
Copy link
Author

Hs293Go commented Jun 26, 2018

Exception in thread "main" java.lang.UnsupportedClassVersionError: me/drton/jmavsim/Simulator has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I ran into this too. In my case I didn't do a clean build. Deleting all of out/ solved the problem for me.

On a side note, I've been using ROS Melodic with PX4/MAVROS with no problem. Let me know if there's anything I can do to help with the migration to Melodic (or updating stuff abt jMavsim)

@julianoes
Copy link
Contributor

I just ran into this again. Oracle Java is not needed, OpenJDK 8 is fine.
However, this workaround is needed:

sudo gedit /etc/java-8-openjdk/accessibility.properties

and comment out the following line like this:

#assistive_technologies=org.GNOME.Acessibility.AtkWrapper

Fix found here: https://askubuntu.com/questions/695560

@julianoes
Copy link
Contributor

@hamishwillee we could add a note in a troubleshooting section

@julianoes
Copy link
Contributor

@hamishwillee we could add a note in a troubleshooting section

Done: PX4/PX4-Devguide#846

@hamishwillee
Copy link
Contributor

Thanks @julianoes . Merged. I was aware of that, but it was still sitting on my todo list. Much appreciated.

@NotBikappa
Copy link

@julianoes thanks, it worked for me

@rk800506
Copy link

rk800506 commented Feb 21, 2020

I just ran into this again. Oracle Java is not needed, OpenJDK 8 is fine.
However, this workaround is needed:

sudo gedit /etc/java-8-openjdk/accessibility.properties

and comment out the following line like this:

#assistive_technologies=org.GNOME.Acessibility.AtkWrapper

Fix found here: https://askubuntu.com/questions/695560

The line is already commented out, but the error is still there, please give some solution to this

@julianoes
Copy link
Contributor

https://dev.px4.io/master/en/simulation/jmavsim.html#troubleshooting

Do this before trying again:

rm -rf Tools/jMAVSim/out

@DronecodeBot
Copy link

This issue has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/error-on-jmavsim-simulation/33908/2

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

8 participants