Skip to main content

UnsatisfiedLinkError?

2 replies [Last post]
bergman
Offline
Joined: 2009-01-06
Points: 0

This is probably the wrong forum to post java questions, but I am very new to the Java world and have no idea where to post such a question. I looked around and could not find a more suitable place to post If this is the wrong place, could someone please point me in the right direction? Thanks!

As for the problem:

I have inherited a project written in Java (using netbeans as an IDE) that contains a call to a native function. My understanding is that this is called from a shared library file - written in C++. The library seems to load correctly, but the function call throws an UnsatisfiedLinkError.

Interestingly, this code has worked in the past on another computer (since reformatted and not reloaded as of yet), but does not work on this one. That makes me think it's an environment or a compiler issue. Based on my limited java debugging skills, I have tried ldd (which shows no missing dependencies) and objdump -a which returns 'file format elf64-x86-64' for the .so and 'File format not recognized' for the binary :-/

I can understand if no one would be able to help since this code was all written in house, but google searches have been of no help, and I'm not sure where else to turn.

A little more info now:

Stack Trace =

java.lang.UnsatisfiedLinkError: netvis.interdml.DMLNativeInterface.LoadDML([Ljava/lang/String;Ljava/util/LinkedList;)Lnetvis/dml/Node;
at netvis.interdml.DMLNativeInterface.LoadDML(Native Method)
at netvis.Project.parse(Project.java:119)
at netvis.Project.open(Project.java:137)
at netvis.ui.MainForm.createProject(MainForm.java:406)
at netvis.NetVisApp.run(NetVisApp.java:115)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Call from java side that throws the exception:

<br />
	      try {<br />
//This line--->	         netvis.dml.Node nodeTree = DMLNativeInterface.LoadDML(filePaths,log);<br />
	         objectTree = new TopLevel(nodeTree);<br />
            for (String s : log) System.out.println(s);<br />
	      } catch (UnsatisfiedLinkError e)<br />
              {<br />
                e.printStackTrace();<br />
              }<br />
              catch (Exception e) {<br />
                e.printStackTrace();<br />
	      }</p>
<p>

Definition in java:

public static native netvis.dml.Node LoadDML(String [] files, LinkedList log);

Definition in c++ library source code:

<br />
// DMLNativeInterface.LoadDML method<br />
//extern "C"{<br />
JNIEXPORT jobject JNICALL Java_netvis_interdml_DMLNativeInterface_LoadDML<br />
  (JNIEnv * env, jclass theClass, jobjectArray stringArray, jobject outList)<br />
{<br />

I've tried making it extern "C" to no avail.

Thanks! Any help is appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
peter__lawrey
Offline
Joined: 2005-11-01
Points: 0

Welcome to the Sun fora.
The forum topics on java.net are rather specific to the development of Java itself.
A forum which may be useful in future is the "New to Java" forum
http://forums.sun.com/forum.jspa?forumID=54

However for this specific problem
http://forums.sun.com/forum.jspa?forumID=52

Your UnsatifiedLinkError is likely due to failing to load a shared library which your application references. This could be because the directory it is in is not in your LD_LIBRARY_PATH or the library was not compiled for the platform of your new machine.

If you don't get much help here, you can post on a second forum, but make it clear this is what you are doing and place a link from one posting to the other.

bergman
Offline
Joined: 2009-01-06
Points: 0

Thank you for the welcome, the help, and the redirection. I didn't think this was the right place to go, but wasn't sure where would be better.

As for my problem, I am starting to think you are in right in that it is not recompiling properly on my new machine. However, I am not sure why not as of yet.

For anyone interested in following this discussion, here is the thread I started on sun.com: http://forums.sun.com/thread.jspa?messageID=10565938&#10565938