Browse Source

catch UnsatisfiedLinkError on JNA load

This catches UnsatifiedLinkError when attempting to load the JNA Native
class, in cases where there are error loading the native libraries that JNA
needs to function.
jaymode 10 years ago
parent
commit
6d96bfc98b
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/main/java/org/elasticsearch/bootstrap/Natives.java

+ 6 - 4
src/main/java/org/elasticsearch/bootstrap/Natives.java

@@ -34,12 +34,14 @@ class Natives {
 
     static {
         try {
-            // load one of the main JNA classes to see if the classes are available. this does not ensure that native
-            // libraries are available
+            // load one of the main JNA classes to see if the classes are available. this does not ensure that all native
+            // libraries are available, only the ones necessary by JNA to function
             Class.forName("com.sun.jna.Native");
             jnaAvailable = true;
-        } catch(ClassNotFoundException e) {
-            logger.warn("JNA not found. native methods will be disabled.");
+        } catch (ClassNotFoundException e) {
+            logger.warn("JNA not found. native methods will be disabled.", e);
+        } catch (UnsatisfiedLinkError e) {
+            logger.warn("unable to load JNA native support library, native methods will be disabled.", e);
         }
     }