java.lang.UnsatisfiedLinkError
Guys, I have done everything but cannot fix this error.. its been past three days i am stuck with this problem and writing here as my last resort...Can anyone plz help..
This is my entire stack trace
java.lang.UnsatisfiedLinkError: com.broadmediatechnology.getmetv.server.getmetvnative.NativeManager.init()Z
com.broadmediatechnology.getmetv.server.getmetvnative.NativeManager.init(Native Method)
com.broadmediatechnology.getmetv.server.GetMeTVManager.init(GetMeTVManager.java:40)
com.broadmediatechnology.getmetv.server.StartupServlet.init(StartupServlet.java:43)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:619)
All I am trying to do is to call a Native Method from my servlet.. Here is my servlet init method
publicvoid init(ServletConfig servletConfig)throws ServletException{
super.init(servletConfig);
GetMeTVManager mng =new GetMeTVManager();
mng.init();
//Some more code here
}
This is GetMeTVManager Class
publicclass GetMeTVManager{
privatestaticboolean started =false;
static NativeManager nm;
publicboolean init(){
try{
nm =new NativeManager();
nm.init();
// Some Mode code here
This is my Native Manager Class
publicclass NativeManager{
publicnativeboolean init();
// SOme more native methods here
static{
try{
System.loadLibrary("getmetv");
System.out.println("Library Loaded");
}
catch (Exception e){
e.printStackTrace();
}
}
}
I am deploying my application as a JAR file within APACHE AXIS environment, my libgetmetv.SO file is in /usr/lib which is set as java.library.path
Everything works fine when I run from command line, but no luck when I run from this servlet.
Any ideas plz?
Thanks
[3757 byte] By [
mraheela] at [2007-11-26 19:47:38]

# 2
I have a similar problem. I was able to compile and run my program from DOS command line. But any attempt to integrate the same code somewhere else is failing.
Please advice!
I have been getting java.lang.UnsatisfiedLinkError exception and now at loss what else should be done.
I build small sample program. Here are details:
1. Operation System: Windows XP
Sun JVM: j2sdk1.4.2_13
2. Base directory: C:\b\004
3. Native.java
public class Native
{
public native int returnValue();
public void getReturnValue()
{
int lRetVal = returnValue();
}
public static void main(String[] args)
{
System.loadLibrary("NativeJNI");
Native lNative = new Native();
lNative.getReturnValue();
}
}
4. I have Microsoft Visual Studio 2005 installed.
I use Visual Studio tool to open DOS command prompt.
At DOS command line, change directory to:C:\b\004
5. At DOS command line, issue the following commands.
Compile Java code:
javac Native.java
This creates Native.class file
Build C++ Header:
javah Native
This creates Native.h file.
6. The content of Native.h file is:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Native */
#ifndef _Included_Native
#define _Included_Native
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class:Native
* Method:returnValue
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_Native_returnValue
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
7. At c:\b\004 directory, I create Native.cpp file:
#include "Native.h"
#include <string.h>
JNIEXPORT jint JNICALL Java_Native_returnValue
(JNIEnv *, jobject)
{
return 5;
}
void main(){}
8. At DOS command line, I issue the following command:
(All at one line)
c:\b\004> cl -Ic:\j2sdk1.4.2_13\include -Ic:\j2sdk1.4.2_13\include\win32 -LD Native.cpp -FeNativeJNI.dll
This creates following files:
NativeJNI.dll
NativeJNI.lib
NativeJNI.exp
9. Now I need to make sure that DLL could be located by Java program. I placed DLL, LIB, and EXP files at C:\WINNT\system32 directory.
10. At DOS command line, I issue the following command:
c:\b\004> java Native
This program worked and I have got the following console output:
Returned Value: 5
11. So far everything worked.
Next, I have tried to use Eclipse.
I have created Eclipse project.
At Eclipse, the only change at Native.java that was introduced was a 損ackage?line:
package nk.jni.simple;
public class Native
{
public native int returnValue();
public void getReturnValue()
{
int lRetVal = returnValue();
}
public static void main(String[] args)
{
System.loadLibrary("NativeJNI");
Native lNative = new Native();
lNative.getReturnValue();
}
}
I complied and run the program.
Now, I have got the following exception:
java.lang.UnsatisfiedLinkError: returnValue
at nk.jni.simple.Native.returnValue(Native Method)
at nk.jni.simple.Native.getReturnValue(Native.java:15)
at nk.jni.simple.Native.main(Native.java:30)
Exception in thread "main"
What did I do wrong?