My company is moving to a target architecture that uses Ubuntu; we are migrating java applications from Windows. Our first application is running into this error on Ubuntu (runs fine on Win):
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: > org/apache/cxf/jaxrs/lifecycle/ResourceProvider
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.lifecycle.ResourceProvider
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 7 more
Both environments are running java 1.8 jdk/jre (NOT OpenJDK on Ubuntu). We use an internal CodeCloud for git and everything is updated in both Win and Ubuntu. Maven shows all the dependencies have been met; I can even expand the maven classes and can see the ResourceProvider class.
I have read about versioning problems with Spring and CXF, but that refers to a version of CXF older than we are running, and I don't see anything that indicates why the code would run in the Windows environment, but not the 'nix environment. Also a lot of talk about WebLogic, where we are using embedded Jetty with CXF for the server side. This is a standalone console application that is not using a container, if that even matters.
Any thoughts or tips would be appreciated.
Edit: This error is occurring using 'run as java' in eclipse. Debugger doesn't even hit the first line of code in main.
Copyright Notice:Content Author:「EricO」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/68292183/java-errors-that-dont-occur-on-windows-but-do-in-ubuntu