-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.UnsatisfiedLinkError: org.apache.tomcat.jni.Library.version(I)I #136
Comments
Hmm ... so grpc-java FYI, grpc-java should be releasing soon. Once the new release is available, upgrading should do the trick. |
I could be wrong but it seems like the new logic adds capabilities needed for the Uber jar where the native libraries have the classifier in the name. Regardless I did actually switch to CR4 and paid closer attention when stepping through the code in the debugger (albeit on When NativeLibraryLoader.load(...) is invoked with first
The second invocation with However the UnsatisfiedLinkError is still thrown as originally described on both osx-x86_64 and linux-x86_64.
|
Ah you're right, my mistake. Can replicate the problem outside of tomcat? |
It seems that I have the same/similar problem -- netty-tcnative-boringssl-static in tomcat (tomcat8, openjdk8 under centos7) that fails with UnsatisfiedLinkError about Library.version(int). I need it to use HTTP/2 over TLS. I have removed tomcat-jni.jar from tomcat libraries to avoid conflict there. So far I have found an extra hint: if I copy the temporary file that NativeLibraryLoader creates and loads with System.load to eg /usr/lib/libnetty-tcnative.so and try to start tomcat then (so System.loadLibrary succeeds), everything works. So it kind of seems that Runtime.loadLibrary and Runtime.load do something differently. JNI specification was updated for JDK8, but it should be compatible with old usage as far as i understand. |
Further experiments show that it seems to be related to hierarchy of classloaders and to the fact that some (er.. most)of the classes in tcnative are found in tomcat-jni.jar and are loaded during tomcat startup. Replacing tomcat-jni.jar with version that contains just org.apache.tomcat.jni.LibraryNotFoundError "helps". I believe that using some netty-tcnative-specific class instead of org.apache.tomcat.jni.SSL in io.netty.handler.ssl.OpenSsl to find correct classloader might help. |
Can You maybe try to submit a pr?
|
I tried and found out that it is not that simple. Tomcat runs each web app in its own classloader (http://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html) which mostly prefers classes from the app. With notable exception of "system classes" and "servlet apis". Which includes among other things org.apache.tomcat.* .. so as long there is org.apache.tomcat.jni.Library in classpath of "common" classloader of Tomcat, it will be used from there. Also, JVM needs that the native library is loaded by the same classloader as is the class whose methods are implemented. And library is "loaded by" the same classloader that loaded the class which called System.load/System.loadLibrary (or Runtime-equivalents of those). That is, the classloader that loads NativeLibraryLoader .. So, one needs to make sure that org.apache.tomcat.jni.Library (and other relevant classes) are loaded by the same classloader as NativeLibraryLoader. The options of getting netty-tcnative work properly in tomcat seem to be:
Only package renaming might be in the scope of this project but this seems quite unlikely? |
Seems only package renaming will work. |
In case the data is helpful for assessing impact or assigning priority, it seems like Pushy users run into this problem pretty regularly. As an aside, we actually ran into this problem ourselves; my first thought was to create an external RPC service so Pushy doesn't have to run inside a Tomcat container, but my first choice for an RPC framework also suffers from this problem. The irony! ;) |
@xsir I just took a look at your PR but I am not as familiar with the loading of native libraries. Did you fix both the OSGi and non-OSGi case? |
This is already fixed in the master branch as we renamed the package etc. |
I'm attempting to use grpc-java with netty-tcnative-boringssl-static and getting the following exception.
I understand it might complicate things but I'm running inside Tomcat for the time being. I have set the -classpath to the path of netty-tcnative-boringssl-static-1.1.33.Fork14-linux-x86_64.jar as you can see below in the command to execute Tomcat.
I've tried both statically and dynamically linked and keep running across the same exception.
grpc-java = 0.13.2
netty-tcnative-boringssl-static = 1.1.33.Fork14 on linux-x86_64 (also tried dynamic and Fork15)
CCing @nmittler and @normanmaurer per @nmittler
The text was updated successfully, but these errors were encountered: