nutdanai7 / java-simple-serial-connector

Automatically exported from code.google.com/p/java-simple-serial-connector
0 stars 0 forks source link

Failed to load native lib in tomcat webapp #60

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Versions up to 2.8.

the native lib will be loaded from different classloaders in tomcat ;-)...
My workaround is:
 in class SerialNativeInterface in the static initializer:

change line:
  System.load(libFolderPath + fileSeparator + libName);
to:
  try {
    System.load(libFolderPath + fileSeparator + libName);
  } catch (UnsatisfiedLinkError ex) {
    if (ex.getMessage().contains("already loaded in another classloader")) {
    } else {
      throw ex;
    }
  }

the string is in the message of the exception:
class: Classloader
method:    private static boolean loadLibrary1(Class fromClass, final File file)

Original issue reported on code.google.com by arnepl...@gmail.com on 19 Feb 2014 at 9:21

GoogleCodeExporter commented 8 years ago
Sorry, 

the solution provided, does not solve the problem.
The native lib must be loaded by the current classloader - this is only 
possible, with a different name. the diff works for me with tomncat 7.0.41.

Arne

Original comment by arnepl...@gmail.com on 20 Feb 2014 at 2:42

Attachments: