how and from which code are you loading native library?
is that code part of the same module?
Yes, the code that uses the native library is part of the same module. For example, using from my original question, the classes in myjar1.jar are doing JNI calls to the native module in the underlying lib/linux_x86_64 directory.
So, the directory structure looks like this:
The classes in myjar1.jar are doing the JNI calls to libNativeCode.so
However, right now the only way I can get this to work is to export the LD_LIBRARY_PATH to the libNativeCode.so. From what I read, this is not supposed to be necessary.
I suspect the problem might be that you have added an explicit "<resource-root path="lib"/>" to your module definition. This is not necessary and could possibly be confusing the resource loader somehow.
I have tried about every combination of parms in the module.xml that I could find, all to no avail. I tried the resource without a lib reference at all, I tried with just a period, with nothing in the dependencies. I can't seem to get anything to work.
Is it possible that there is some kind of naming convention that must be adhered to for it to work ? What I mean is if the jar is named myjar1.jar, does the native library have to be named libmyjar1.so ??? I sure hope this is not the case because we have one jar and two .so's.
Any recommendation are appreciated. Thanks.
try enabling trace logging for "org.jboss.modules" category
it will help you debug this.
No, there is no special naming convention. At this point random combinations are probably not useful though; some methodical troubleshooting is required. The first thing is to be certain that it is the code in the module which is calling System.loadLibrary() or System.load(), as these methods are sensitive to the class loader of the calling class. Secondly, the only resource roots you need in the descriptor are the two JARs; adding in "." or "lib" may be actively preventative in terms of getting the library to load. So this should be our troubleshooting baseline.
Native library name mapping and loading is not part of the trace logging, so this will not be a useful thing to do. One possibility is to use the Linux strace utility to identify exact path names being opened. The last point I want to emphasize is that paths are case-sensitive, and that you should double-check that you are indeed running on a 64-bit JVM.