0

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.

Community
  • 1
  • 1
Skaÿ
  • 326
  • 1
  • 3
  • 15
  • 1
    Your problem is that your CLASSPATH on the Ubuntu system does **not** contain the javax.activation packages. That can have various reasons; and you know have to do some research how to get the corresponding (missing) stuff on that system. – GhostCat Jan 18 '17 at 08:42
  • Thanks. I modified my original question with new details. Now I have a problem with a class (jdk.management.resource.ResourceRequestDeniedException) that seems to be absent from the classpath. How to add it? – Skaÿ Jan 18 '17 at 10:14
  • This is really strange; that is more or less a system class that is not found. It looks like your whole setup there is somehow messed up. Hard to say ... you *could* try asking on askubuntu.com ... the other thing is ... when it wants to load an exception named ResourceRequestDeniedException ... then you probably have some other problem as well. Anyway, your results look very uncommon; that is hard to debug from remote. You might be better of looking for some experienced human person you can work with directly here. – GhostCat Jan 18 '17 at 10:18
  • Ok Thanks. I will try on askubuntu.com. 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. – Skaÿ Jan 18 '17 at 10:24
  • No response including on askubuntu.com. So I create a custom exception (extends Exception) to see if another problem occurs. No additional problems, the application looks to run properly. Nevertheless no answer was found for the problem above. – Skaÿ Jan 18 '17 at 11:52

0 Answers0