[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JNI unsatisfied link eroor

Posted on 2004-10-12
16
Medium Priority
?
1,068 Views
Last Modified: 2012-05-05
I am writing using JNI to translate web based queries generated in Java classes to C based queries over a socket connection.  Right now all the classes are in the same directory as much of the other C code.  At first, I had an unsatisfied link error due to not setting the proper java library path, but I fixed that.  I am still getting an unsatified link error, but this time in java's main method when invoking the native "submitQuery" method.  I haven't been able to figure out how to resolve this one.  Any assistance would be much appreciated.  This is being compiled and run on a Solaris machine.
0
Comment
Question by:tigress298
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
16 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12287687
The cause is your c++/c dll is not binded correctly with Java API
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 1000 total points
ID: 12287698
The following link may shed some light on this:
http://developer.java.sun.com/developer/bugParade/bugs/4225434.html
0
 

Author Comment

by:tigress298
ID: 12287774
I am getting the following output when running the -verbose:jni command:

sfoste03@sunlp0001-(74): java -verbose:jni JNIQuery
[Loaded native library: /usr/java1.2/jre/lib/sparc/libjava.so]
[Loaded native library: /usr/java1.2/jre/lib/sparc/libzip.so]
[Dynamic-linking native method java/lang/Object.registerNatives ...]
[Dynamic-linking native method java/lang/Class.registerNatives ...]
[Dynamic-linking native method java/lang/Thread.registerNatives ...]
[Dynamic-linking native method java/lang/System.registerNatives ...]
[Dynamic-linking native method java/lang/Class.getPrimitiveClass ...]
[Dynamic-linking native method java/security/AccessController.getStackAccessControlContext ...]
[Dynamic-linking native method java/lang/System.initProperties ...]
[Dynamic-linking native method java/io/FileInputStream.initIDs ...]
[Dynamic-linking native method java/io/FileDescriptor.initIDs ...]
[Dynamic-linking native method java/io/FileOutputStream.initIDs ...]
[Dynamic-linking native method java/lang/System.setIn0 ...]
[Dynamic-linking native method java/lang/ClassLoader.getCallerClassLoader ...]
[Dynamic-linking native method java/lang/Class.forName0 ...]
[Dynamic-linking native method java/security/AccessController.doPrivileged ...]
[Dynamic-linking native method java/lang/System.setOut0 ...]
[Dynamic-linking native method java/lang/System.setErr0 ...]
[Dynamic-linking native method java/lang/Compiler.registerNatives ...]
[Dynamic-linking native method java/io/FileSystem.getFileSystem ...]
[Dynamic-linking native method java/io/UnixFileSystem.initIDs ...]
[Dynamic-linking native method java/security/AccessController.doPrivileged ...]
[Dynamic-linking native method java/io/UnixFileSystem.list ...]
[Dynamic-linking native method java/io/UnixFileSystem.canonicalize ...]
[Dynamic-linking native method java/io/UnixFileSystem.getBooleanAttributes0 ...]
[Dynamic-linking native method java/lang/ClassLoader.findLoadedClass ...]
[Dynamic-linking native method java/lang/ClassLoader.findBootstrapClass ...]
[Dynamic-linking native method java/security/AccessController.doPrivileged ...]
[Dynamic-linking native method java/lang/String.intern ...]
[Dynamic-linking native method java/lang/System.getCallerClass ...]
[Loaded native library: /usr/java1.2/jre/lib/sparc/libzip.so]
[Dynamic-linking native method java/util/zip/ZipFile.initIDs ...]
[Dynamic-linking native method java/util/zip/ZipFile.open ...]
[Dynamic-linking native method java/util/zip/ZipFile.getTotal ...]
[Dynamic-linking native method java/util/zip/ZipFile.getEntry ...]
[Dynamic-linking native method java/util/zip/ZipEntry.initIDs ...]
[Dynamic-linking native method java/util/zip/ZipEntry.initFields ...]
[Dynamic-linking native method java/util/zip/ZipFile.getCSize ...]
[Dynamic-linking native method java/util/zip/ZipFile.getMethod ...]
[Dynamic-linking native method java/util/zip/Inflater.initIDs ...]
[Dynamic-linking native method java/util/zip/Inflater.init ...]
[Dynamic-linking native method java/util/zip/Inflater.inflateBytes ...]
[Dynamic-linking native method java/util/zip/ZipFile.read ...]
[Dynamic-linking native method java/lang/Throwable.fillInStackTrace ...]
[Dynamic-linking native method java/io/FileInputStream.open ...]
[Dynamic-linking native method java/io/UnixFileSystem.getLength ...]
[Dynamic-linking native method java/io/FileInputStream.readBytes ...]
[Dynamic-linking native method java/lang/ClassLoader.defineClass0 ...]
[Unable to load native library: /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so]
ld.so.1: /usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java: fatal: relocation error: file /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so: symbol locs: referenced symbol not found
Exception in thread "main" [Dynamic-linking native method java/lang/Object.getClass ...]
[Dynamic-linking native method java/io/FileOutputStream.writeBytes ...]
java.lang.UnsatisfiedLinkError: no NewServerClient in java.library.path
[Dynamic-linking native method java/lang/Throwable.printStackTrace0 ...]
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.<init>(Throwable.java:94)
        at java.lang.Error.<init>(Error.java:50)
        at java.lang.LinkageError.<init>(LinkageError.java:43)
        at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
        at java.lang.ClassLoader.loadLibrary(Compiled Code)
        at java.lang.Runtime.loadLibrary0(Runtime.java:473)
        at java.lang.System.loadLibrary(System.java:778)
        at <Unloaded Method>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 1000 total points
ID: 12288064
Hi tigress298,

>> [Unable to load native library: /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so]
>> ld.so.1: /usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java: fatal: relocation error: file /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so: symbol locs: referenced symbol not found

>> The cause is your c++/c dll is not binded correctly with Java API
right. you have to use javah on the compiled class. this tool generate a C header file you must use to make your C library.
0
 

Author Comment

by:tigress298
ID: 12288234
I did that.  Below are my steps of creation.

javac JNIQuery.java
javah -jni -o JNIQuery.h JNIQuery
made my NewServerClient.c class with #include "JNIQuery.h"
cc -G -o NewServerClient.so NewServerClient.c
java -verbose:jni JNIQuery
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12290125
Please show the java code where you load the library
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12290213
I want to see your c/c++ code. I suspect memory allocation problems in ur code
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12296011
>>cc -G -o NewServerClient.so NewServerClient.c
You should have in the static statement of your class :
    static{
        System.loadLibrary("NewServerClient"); // no extension
    }


>>ld.so.1: /usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java: fatal: relocation error: >>file /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so: symbol locs: referenced symbol not found

The symbol named "locs" can't be found. You probably forgot to link your library with the one defining this symbol.
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12555221
I suggest to split the points : sudhakar_koundinya, Webstorm
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12584299
????

Some strange thing happened here
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12679509
:-)
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12680445
:-)
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question