ClassNotFoundException with Openjdk on ubuntu - linux

I have a problem with openjdk on ubuntu.
I have a java program that works perfectly on my machine (OSX 10.11). When I try to run it on the ubuntu I encounter errors telling me that classes are missing...
root#syncapp:/home/user# java -jar syncapp.jar
++ System >> Maximum heap size can used : 522190848 bytes
Exception in thread "main" java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base#9-Ubuntu/Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base#9-Ubuntu/NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base#9-Ubuntu/DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(java.base#9-Ubuntu/Method.java:535)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: javax/activation/UnsupportedDataTypeException
at skay.com.xxx.yyy.sync.Application.createPIDFile(Application.java:67)
at skay.com.xxx.yyy.sync.Application.main(Application.java:29)
... 5 more
Caused by: java.lang.ClassNotFoundException: javax.activation.UnsupportedDataTypeException
at java.net.URLClassLoader.findClass(java.base#9-Ubuntu/URLClassLoader.java:388)
at java.lang.ClassLoader.loadClass(java.base#9-Ubuntu/ClassLoader.java:486)
at java.lang.ClassLoader.loadClass(java.base#9-Ubuntu/ClassLoader.java:419)
... 7 more
The line 67 of my "Application.java" file is :
final Matcher PID = Settings.get().patterns.get("PID_HOST").matcher( ManagementFactory.getRuntimeMXBean().getName() ) ;
Here is my configuration:
root#syncapp:/home/user# uname -a
Linux syncapp 4.8.0-22-generic #24-Ubuntu SMP Sat Oct 8 09:15:00 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
root#syncapp:/home/user# java -version
openjdk version "9-Ubuntu"
OpenJDK Runtime Environment (build 9-Ubuntu+0-9b134-2ubuntu1)
OpenJDK 64-Bit Server VM (build 9-Ubuntu+0-9b134-2ubuntu1, mixed mode)
Edit 1 :
Apparently it would come from a problem related to the version of openjdk installed. The following were available:
root#syncapp:/home/user# update-alternatives --config java
Il existe 3 choix pour l'alternative java (qui fournit /usr/bin/java).
Sélection Chemin Priorité État
------------------------------------------------------------
* 0 /usr/lib/jvm/java-9-openjdk-amd64/bin/java 1091 mode automatique
1 /usr/bin/gij-6 1060 mode manuel
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 mode manuel
3 /usr/lib/jvm/java-9-openjdk-amd64/bin/java 1091 mode manuel
Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou choisissez le numéro sélectionné :
And following the message it turns out that JavaFX was not found. And we had to install the openjfx package. What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?
When I see the package page on the ubuntu package website (http://packages.ubuntu.com/yakkety/openjfx), I realized that it seems compatible with version 8 of the openjdk (openjdk-8-jre).
So I run the jar with this JRE and the blocking point previously encountered seems to have gone but another one has appeared. Apparently the following class seems to be absent (from the classpath) jdk/management/resource/ResourceRequestDeniedException.
root#syncapp:/home/user# /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar syncapp.jar
++ System >> Maximum heap size can used : 464519168 bytes
++ System >> PID (2125) created...
++ System >> USR2 Signal handled...
++ System >> Settings file (/home/user/resources/sets.ini) loaded.
++ System >> 4 worker(s) has been created and launched...
++ System >> Worker started (13#741054620)
++ System >> Worker started (10#1702086468)
++ System >> Worker started (11#1289522363)
++ System >> Worker started (12#194404)
[...]
++ System >> Database pool created (4/8)
[...]
Exception in thread "Thread-3" java.lang.NoClassDefFoundError: jdk/management/resource/ResourceRequestDeniedException
at skay.com.xxxx.yyyy.sync.core.job.associate.SynchronizeCalendarWithXXXXXXJob.apply(SynchronizeCalendarWithXXXXXXJob.java:139)
at skay.com.xxxx.yyyy.sync.core.threadpool.Worker.run(Worker.java:70)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: jdk.management.resource.ResourceRequestDeniedException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
So how I can add this library to the classpath please?
Edit 2 :
Just a small clarification regarding the "ResourceRequestDeniedException" exception. I voluntarily call it in my code in the case of a response to an HTTP request with a return code designating an error. For example here is the piece of code concerned by the exception mentioned above.
if( con == null || con.getResponseCode() != 200 )
throw new ResourceRequestDeniedException() ;
Where "con" is an "HttpURLConnection" object.
Edit 3 :
No response including on askubuntu.com. So I create a custom exception (extends Exception) to replace ResourceRequestDeniedException to see if another problem occurs. No additional problems, the application looks to run properly.

Related

What causes this fatal error in the Amazon Corretto JVM?

When running my application on the Amazon Corretto JVM I encountered the following error. What does this mean?
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fcde9765caa, pid=1, tid=144
#
# JRE version: OpenJDK Runtime Environment Corretto-11.0.18.10.1 (11.0.18+10) (build 11.0.18+10-LTS)
# Java VM: OpenJDK 64-Bit Server VM Corretto-11.0.18.10.1 (11.0.18+10-LTS, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xc03caa] ObjectSampleCheckpoint::add_to_leakp_set(Method const*, unsigned long)+0x7a
When reporting a JVM crash, always include hs_err.log dump produced by the JVM. A short error message is not enough to provide a definitive conclusion.
In your case, however, the reason is most likely the JVM bug JDK-8236743.
Upgrade to JDK 17+ where the issue is already fixed or disable OldObjectSample events in your JFR recording.

Unable to Connect Sqoop to Oracle TimesTen through JDBC on Linux

I have installed Timesten database (full version) on linux (Linux is guest OS installed through Oracle viritual box with cloudera VM)
I am trying to run following sqoop command on linux and getting below errors
command
sqoop list-tables --connect jdbc:timesten:direct:dsn=sampledb_1122 --driver com.timesten.jdbc.TimesTenDriver
**error**
ERROR manager.SqlManager: Error reading database metadata: java.sql.SQLException: Problems with loading native library/missing methods: no ttJdbc in java.library.path
java.sql.SQLException: Problems with loading native library/missing methods: no ttJdbc in java.library.path
at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1809)
at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:305)
at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:161)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:878)
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
at org.apache.sqoop.manager.SqlManager.listTables(SqlManager.java:520)
at org.apache.sqoop.tool.ListTablesTool.run(ListTablesTool.java:49)
at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
at org.apache.sqoop.Sqoop.main(Sqoop.java:236)
Could not retrieve tables list from server
18/02/18 18:56:04 ERROR tool.ListTablesTool: manager.listTables() returned null
TimesTen bin and lib folder location
/home/cloudra/timesten/TimesTen/tt1122_64/bin
/home/cloudera/timesten/TimesTen/tt1122_64/lib
Following values are setup in my environment and other parameters
USERNAME=cloudera
DESKTOP_SESSION=gnome
MAIL=/var/spool/mail/cloudera
PATH=/var/lib/sqoop:/home/cloudera/timesten/TimesTen/tt1122_64/bin:/home/cloudera/timesten/TimesTen/tt1122_64/lib:/home/cloudera/anaconda3/bin:/var/lib/sqoop:/home/cloudra/timesten/TimesTen/tt1122_64/bin:/home/cloudera/timesten/TimesTen/tt1122_64/lib:/home/cloudera/anaconda3/bin:/home/cloudera/anaconda3/bin:/usr/local/firefox:/sbin:/usr/java/jdk1.7.0_67-cloudera/bin:/usr/local/apache-ant/apache-ant-1.9.2/bin:/usr/local/apache-maven/apache-maven-3.0.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/cloudera/bin
PWD=/home/cloudera
THREAD_FLAGS=native
HOME=/home/cloudera
SHLVL=2
M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
LOGNAME=cloudera
CVS_RSH=ssh
CLASSPATH=/home/cloudera/timesten/TimesTen/tt1122_64/lib/ttjdbc6.jar
[cloudera#quickstart ~]$ echo $LD_LIBRARY_PATH
/home/cloudera/timesten/TimesTen/tt1122_64/lib:/home/cloudera/timesten/TimesTen/tt1122_64/lib:
[cloudera#quickstart ~]$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
[cloudera#quickstart ~]$
cloudera#quickstart bin]$ ./ttversion
TimesTen Release 11.2.2.8.0 (64 bit Linux/x86_64) (tt1122_64:53396) 2015-01-20T08:36:31Z
Instance admin: cloudera
Instance home directory: /home/cloudera/timesten/TimesTen/tt1122_64
World accessible
Daemon home directory: /home/cloudera/timesten/TimesTen/tt1122_64/info
PL/SQL enabled.
In addition to above.. the ttjdbc6.jar file is located at following location
[cloudera#quickstart sqoop]$ pwd
/var/lib/sqoop
[cloudera#quickstart sqoop]$ ls -ltr
total 0
lrwxrwxrwx 1 root root 40 Jun 9 2015 mysql-connector-java.jar -> /usr/share/java/mysql-connector-java.jar
lrwxrwxrwx 1 root root 58 Feb 16 21:37 ttjdbc6.jar -> /home/cloudera/timesten/TimesTen/tt1122_64/lib/ttjdbc6.jar
[cloudera#quickstart timesten]$ pwd
/usr/lib/timesten
[cloudera#quickstart timesten]$ ls -ltr
total 276
-rwxrwxrwx 1 root root 279580 Feb 18 11:33 ttjdbc6.jar
Java_library_path output
[cloudera#quickstart timesten]$ java -XshowSettings:properties
Property settings:
awt.toolkit = sun.awt.X11.XToolkit
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.awt.printerjob = sun.print.PSPrinterJob
java.class.path = /home/cloudera/timesten/TimesTen/tt1122_64/lib/ttjdbc6.jar
java.class.version = 51.0
java.endorsed.dirs = /usr/java/jdk1.7.0_67-cloudera/jre/lib/endorsed
java.ext.dirs = /usr/java/jdk1.7.0_67-cloudera/jre/lib/ext
/usr/java/packages/lib/ext
java.home = /usr/java/jdk1.7.0_67-cloudera/jre
java.io.tmpdir = /tmp
java.library.path = /home/cloudera/timesten/TimesTen/tt1122_64/lib
/home/cloudera/timesten/TimesTen/tt1122_64/lib
/usr/java/packages/lib/amd64
/usr/lib64
/lib64
/lib
/usr/lib
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.7.0_67-b01
I execute ttenv.sh scripts but it is not setting up any parameter when I check env parameters, so I had to do it manually.
Gurus and experts.. please help me here.. not sure what is the issue and why I am getting the above error.
Thanks for your help..
The key line here is this:
java.sql.SQLException: Problems with loading native library/missing methods:
no ttJdbc in java.library.path
The TimesTen JDBC driver is a type 1 / 2 driver and it relies on the underlying TimesTen native libraries. Specifically it needs several shared libraries located in <TimesTen_install_dir>/lib such as libttJdbc.so (the one that the error is complaining about), libtten.so etc. Typically you need to make sure that the java.library.path includes this directory (which it appears is the case) and that the CLASSPATH includes the ttjdbc7.jar file in that directory. Another possibility is that your TimesTen installation is a 'client only' installation in which case you cannot use the 'direct' driver and if you try to do so then you would get this exact error. I suggest checking to see if you actually have the files libttJdbc.so and libtten.so in <TimesTen_install_dir>/lib and if not, then this means you have a client only install and need to configure / use client/server connectivity instead.

Linux JNA-based affinity not usable because it failed to load

I have a listener project implemented on java that consumes the data from kafka and pushes into the Vanilla Chronicle queue. I am using the java libraries of jna, jna-platform version 4.4.0 and chronicle queue version 3.6.4. When I run the project on Windows it successfully consumes and pushes the data into the queue. However when I run it on "Ubuntu 16.04.3 LTS" that is located on Azure VM while pushing the data into the queue it fails. And on also when I run it on my local ubuntu that is in VMware it also succesfully runs. Anyone has an idea what the problem is? The execution log is below:
*WARN [main] (net.openhft.affinity.Affinity:149):
Linux JNA-based affinity not usable because it failed to load! Reason: java.lang.ExceptionInInitializerError
at net.openhft.affinity.Affinity.isLinuxJNAAffinityUsable(Affinity.java:113)
at net.openhft.affinity.Affinity.<clinit>(Affinity.java:52)
at net.openhft.affinity.AffinitySupport.getThreadId(AffinitySupport.java:26)
at net.openhft.chronicle.VanillaChronicle$VanillaAppenderImpl.startExcerpt(VanillaChronicle.java:628)
at net.openhft.chronicle.VanillaChronicle$VanillaAppenderImpl.startExcerpt(VanillaChronicle.java:615)
at com.myproject.queue.DataQueueManager.add(DataQueueManager.java:55)
at com.myproject.listener.myprojectListener.initKafka(myprojectListener.java:67)
at com.myproject.listener.myprojectListener.start(myprojectListener.java:43)
at com.myproject.listener.myprojectListener.main(myprojectListener.java:35)
Caused by: java.lang.IllegalStateException: sched_getaffinity(0, (8) , cpuset) failed; errno=22
at net.openhft.affinity.impl.LinuxHelper.sched_getaffinity(LinuxHelper.java:61)
at net.openhft.affinity.impl.LinuxJNAAffinity.getAffinity(LinuxJNAAffinity.java:62)
at net.openhft.affinity.impl.LinuxJNAAffinity.<clinit>(LinuxJNAAffinity.java:49)
... 9 more
Caused by: com.sun.jna.LastErrorException: [22] H"
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:390)
at com.sun.jna.Function.invoke(Function.java:323)
at com.sun.jna.Library$Handler.invoke(Library.java:236)
at net.openhft.affinity.impl.$Proxy7.sched_getaffinity(Unknown Source)
at net.openhft.affinity.impl.LinuxHelper.sched_getaffinity(LinuxHelper.java:56)
... 11 more
07.09.2017 12:58:28.631 WARN [main] (net.openhft.affinity.Affinity:149):
Posix JNA-based affinity not usable because it failed to load! Reason: java.lang.ExceptionInInitializerError
at net.openhft.affinity.Affinity.isPosixJNAAffinityUsable(Affinity.java:99)
at net.openhft.affinity.Affinity.<clinit>(Affinity.java:56)
at net.openhft.affinity.AffinitySupport.getThreadId(AffinitySupport.java:26)
at net.openhft.chronicle.VanillaChronicle$VanillaAppenderImpl.startExcerpt(VanillaChronicle.java:628)
at net.openhft.chronicle.VanillaChronicle$VanillaAppenderImpl.startExcerpt(VanillaChronicle.java:615)
at com.myproject.queue.DataQueueManager.add(DataQueueManager.java:55)
at com.myproject.listener.myprojectListener.initKafka(myprojectListener.java:67)
at com.myproject.listener.myprojectListener.start(myprojectListener.java:43)
at com.myproject.listener.myprojectListener.main(myprojectListener.java:35)
Caused by: java.lang.IllegalStateException: sched_getaffinity((4) , &(allocated#0x7f2ba436c7e0 (4 bytes) (com.sun.jna.ptr.IntByReference#a437470b)) ) errorNo=22
at net.openhft.affinity.impl.PosixJNAAffinity.getAffinity(PosixJNAAffinity.java:125)
at net.openhft.affinity.impl.PosixJNAAffinity.<clinit>(PosixJNAAffinity.java:64)
... 9 more
Caused by: com.sun.jna.LastErrorException: [22] ý
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:390)
at com.sun.jna.Function.invoke(Function.java:323)
at com.sun.jna.Library$Handler.invoke(Library.java:236)
at net.openhft.affinity.impl.$Proxy8.sched_getaffinity(Unknown Source)
at net.openhft.affinity.impl.PosixJNAAffinity.getAffinity(PosixJNAAffinity.java:117)
... 10 more
07.09.2017 12:58:28.633 INFO [main] (net.openhft.affinity.Affinity:61):
Using dummy affinity control implementation
07.09.2017 12:58:28.634 ERROR [main] (com.myproject.listener.myprojectListener:71):
java.lang.UnsupportedOperationException*
Caused by: com.sun.jna.LastErrorException: [22] H"
Error code 22 from the linux source is EINVAL [1].
Looking at the man page for the function sched_getaffinity shows the reason for EINVAL being returned:
EINVAL (sched_getaffinity() and, in kernels before 2.6.9, sched_setaffinity()) cpusetsize is smaller than the size of the affinity mask used by the kernel.
This could be an issue in the library, but is more likely due to the runtime environment and the way that the VM infrastructure is reporting/using CPU masks.
As Peter has pointed out, the value of setting process affinity in a virtualised environment is questionable.
1) http://elixir.free-electrons.com/linux/v4.4.84/source/include/uapi/asm-generic/errno-base.h#L25

Anyone experiencing Error code -46 on Java SDK 1.20

Latest Java SDK (1.20) seems to throw NoSuchMethodError when trying to autheticate with the accesspoint using onAuthenticationRequired() ; Once the exception is thrown then all subsequent attempt to connect to the bridge will result in " Error - Code 46 Message bridge not responding"
Anyone experiencing this behaviour, code is executed on
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.8) (6b27-1.12.8)
OpenJDK Zero VM (build 20.0-b12, mixed mode)
Exception in thread "Thread-25" java.lang.NoSuchMethodError: java.lang.Integer.compare(II)I
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager$1.compare(PHBridgeVersionManager.java:83)
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager$1.compare(PHBridgeVersionManager.java:1)
at java.util.Arrays.mergeSort(Arrays.java:1283)
at java.util.Arrays.mergeSort(Arrays.java:1294)
at java.util.Arrays.sort(Arrays.java:1223)
at java.util.Collections.sort(Collections.java:176)
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager.setFallbackBridgeVersion(PHBridgeVersionManager.java:130)
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager.setBridgeVersion(PHBridgeVersionManager.java:365)
at com.philips.lighting.hue.sdk.connection.impl.PHBridgeInternal.processResponse(PHBridgeInternal.java:450)
at com.philips.lighting.hue.sdk.connection.impl.PHBridgeInternal$1.run(PHBridgeInternal.java:122)
Integer.compare was introduced in Java 7 and you're clearly using Java 6 based on the error message.
Try using Java 7 or Java 8.

JVM crashes when running SOAPUI on Ubuntu

I just downloaded SOAPUI 4.0.1 and tried to run it in Ubuntu 11.10. I run the file soapui.sh. The application started up and the window actually appeared, but then after a few seconds it closed. Looking at the terminal I saw that the JVM crashed. Below are the details of the error:
(process:4183): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.30.0/./gobject/gtype.c:2708: You forgot to call g_type_init()
(process:4183): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
(process:4183): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed
Problematic frame:
C [libgconf-2.so.4+0x15b99] gconf_enum_to_string+0xd59
Can anyone help? Thanks.
Look here: http://www.eviware.com/forum/viewtopic.php?f=13&t=7736
Look in ..../soapui-4.0.1/bin/soapui.sh:
#uncomment to disable browser component
#JAVA_OPTS="$JAVA_OPTS -Dsoapui.jxbrowser.disable=true" <- uncomment this line
if you are usising soapui.sh to start soapUI. If you used installer and using launcher than
in soapUI-*.vmoptions add -Dsoapui.jxbrowser.disable=true
that should do the trick.
I also have the same issue
--
DUMP
...
# JRE version: 6.0_33-b03
# Java VM: Java HotSpot(TM) Server VM (20.8-b03 mixed mode linux-x86 )
# Problematic frame:
# C [libgconf-2.so.4+0x176aa] __float128+0x176aa
...
OS:Fedora release 16 (Verne)
uname:Linux 3.3.2-6.fc16.i686 #1 SMP Sat Apr 21 13:23:12 UTC 2012 i686
libc:glibc 2.14.90 NPTL 2.14.90
...
--
This jxbrowser...jar is working with xulrunner-2.8...jar and native code doesn't full compatible with your OS dependencies.
jxbrowser it's used for 'HTML rendering' but works also without it.
--
It works also in FC16

Resources