FirebirdSQL / jaybird

JDBC driver for Firebird
https://firebirdsql.org/en/jdbc-driver/
GNU Lesser General Public License v2.1
94 stars 23 forks source link

NativeResourceUnloadWebListener fails when JNA is not on the class path. #686

Closed mrotteveel closed 2 years ago

mrotteveel commented 2 years ago

The NativeResourceUnloadWebListener fails when JNA is not on the classpath as reported on https://groups.google.com/g/firebird-java/c/aRrtXQGR5Dg, as it will fail to find com.sun.jna.Library when loading FbClientLibrary. The lookup of the class loader should be isolated, or any errors when loading it should be swallowed.

Exception sending context initialized event to listener instance of class [org.firebirdsql.gds.ng.jna.NativeResourceUnloadWebListener]
java.lang.NoClassDefFoundError: com/sun/jna/Library
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2478)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:870)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1371)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1215)
        at org.firebirdsql.gds.ng.jna.NativeResourceUnloadWebListener.jaybirdLoadedInContext(NativeResourceUnloadWebListener.java:54)
        at org.firebirdsql.gds.ng.jna.NativeResourceUnloadWebListener.contextInitialized(NativeResourceUnloadWebListener.java:40)

Workarounds:

mrotteveel commented 2 years ago

Fixed by checking class loader of FbClientDatabaseFactory instead.