nativelibs4java / BridJ

BridJ: blazing fast Java / C / C++ interop
https://code.google.com/archive/p/bridj/
Other
296 stars 77 forks source link

JNAerator: JNA not working from Weblogic? #14

Open ochafik opened 9 years ago

ochafik commented 9 years ago

From @lagarcia on March 1, 2012 15:57

Hi

Recently I was trying to use JNA/JNAerator in order to invoke methods from a C library within a Java 6 application. I was having some troubles doing the same thing using JNI because an error was raising from a method within the C native library when I executed the Java app.

The thing is that with JNA I was able to skip the error that I was catching when using JNI, but when I included the functionality that was making use of the C native library via JNA within a web application deployed on Weblogic, it didn't seem to work correctly. The native method that seems to fail is loading a file from a file path that is passed as argument. The raising error suggests that the file is not loaded. When using the same function from the standalone app it was working fine, but not from within the web app deployed on Weblogic. The libraries seem to be loaded fine. I didn't try with other app servers.

Do you have any experience or feedback using JNA from web apps?

Thanks and regards, Luis

Copied from original issue: ochafik/nativelibs4java#277

ochafik commented 9 years ago

Hi @lagarcia ,

I'm afraid I'm unable to provide support for the JNA runtime library (for that I would recommend using the JNA users mailing list).

However, I would encourage you to try using BridJ in your application instead of JNA (you just need to use the latest JNAerator with "-runtime BridJ" instead of "-runtime JNA") : if it still doesn't work then, I'll be glad to investigate what's going on there.

Cheers

ochafik commented 9 years ago

From @lagarcia on March 5, 2012 15:57

Hi Olivier,

Thanks for your swift reply. Actually I was trying with BridJ as well, but I'm having this "UnsatisfiedLinkError" issue:

GRAVE: Unable to create low-level struct metadata for es.indra.freeflow.sh130.fpengine.vrslib.VrsLibrary$CVrsString : won't be able to use it as a by-value function argument. java.lang.UnsatisfiedLinkError: org.bridj.dyncall.DyncallLibrary.dcNewStruct(JI)Lorg/bridj/Pointer; at org.bridj.dyncall.DyncallLibrary.dcNewStruct(Native Method) ...

Does it have any relation with the "dyncall" library? What does it mean? The native library that I'm trying to use is correctly linked and it doesn't have any additional dependency.

Thanks and regards Luis

ochafik commented 9 years ago

Hi @lagarcia ,

This log is misleading, I will update it to be a warning rather than an error : it reflects the unfinished / experimental state of support for struct-by-value arguments and return values for functions (support is being worked on, but status is more advanced on Unix than on Windows :-))

This means that a function like the following is not supported yet : struct s f(struct s);

As opposed to the following that is supported fine : struct s* f(struct s*);

Does your native code contain such struct-by-value functions ?

Cheers