java.lang.UnsatisfiedLinkError
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, July 19, 2006 11:18 PM

when i run the JNI using doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException, it runs ok without error but when i run using process(ActionContext context, HttpServletRequest req, HttpServletResponse res) throws UIException, it gives me java.lang.UnsatisfiedLinkError. below is my source code for JNIWrapper and servlet file JNIWrapper.java public class JNIWrapper { static { System.loadLibrary("CalcCore"); } public native boolean initApi(); public native String createPolicy(String s); public native String doIllustration(int h, String s); public native void uninit   More>>

when i run the JNI using doGet(HttpServletRequest request,
HttpServletResponse response)throws ServletException, IOException, it runs ok without error but when i run using process(ActionContext context, HttpServletRequest req, HttpServletResponse res) throws UIException, it gives me java.lang.UnsatisfiedLinkError.

below is my source code for JNIWrapper and servlet file


JNIWrapper.java



public class JNIWrapper {



static {
System.loadLibrary("CalcCore");
}


public native boolean initApi();


public native String createPolicy(String s);

public native String doIllustration(int h, String s);


public native void uninitApi();


public JNIWrapper() {
}


public String CreatePolicy(String xmlInput) {
return createPolicy(xmlInput);
}


public String DoIllustration(int handle) {
return doIllustration(handle, "");
}


protected void finalize() {
uninitApi();
}


}


JNLProds.java (with doGet() method)


public class JNLProds extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
JNIWrapper jni = new JNIWrapper();

jni.CreatePolicy("abc");

}
}

JNLProds.java (with process() method)


public class JNLProds extends HttpServlet implements ActionServlet, UIConstants {
public void process (ActionContext context, HttpServletRequest req, HttpServletResponse res) throws UIException {
JNIWrapper jni = new JNIWrapper();

jni.CreatePolicy("abc");

}
}

this is the c++ source code that using JNI native method



#include "JNIWrapper.h"
JNIEXPORT jboolean JNICALL Java_JNLTermCalcEngine_initApi
(JNIEnv *env, jobject obj) {


char l_DataPath[30] = "C:\Jackson\Life\Data\";

illBase::SetDataPath(l_DataPath);

return DllInit();

}

JNIEXPORT jstring JNICALL Java_JNLTermCalcEngine_createPolicy
(JNIEnv *env, jobject obj, jstring nString) {
jboolean isCopy = true;

string inString = "";

string tmpStr = "xyz";

const char* pInString = NULL;

pInString = env->GetStringUTFChars(nString, &isCopy);

inString.insert(0,pInString);

if(isCopy == JNI_TRUE)
env->ReleaseStringUTFChars(nString,(const char*) inString.c_str());

return (jstring) env->NewStringUTF((const char*) tmpStr.c_str());

}

JNIEXPORT jstring JNICALL Java_JNLTermCalcEngine_doIllustration
(JNIEnv *env, jobject obj, jint iHandler, jstring nString) {
jboolean isCopy = true;

string inString = "";

string outString = "";

string tmpString = "1234";

inString.insert(0,env->GetStringUTFChars(nString, &isCopy));

if(isCopy == JNI_TRUE)
env->ReleaseStringUTFChars(nString,NULL);
return (jstring) env->NewStringUTF((const char*) tmpString.c_str());

}

JNIEXPORT void JNICALL Java_JNLTermCalcEngine_uninitApi
(JNIEnv *env, jobject obj) {
DllUninit();

}


FYI, i put my "CalcCore.dll" which is compiled in c++ in JAVA_HOME in directory and all my JNIWrapper.class and JNLProds.class in CATALINA_HOMEwebappsjniWEB-INFclasses
folder and my jsp file in CATALINA_HOMEwebappsjnijsp folder


so, may i know the reason that i can successfully run in doGet() method but it fails when run in process() method?


Thank you.


ectoh

   <<Less

Re: java.lang.UnsatisfiedLinkError

Posted By:   Nicol_Saraova  
Posted On:   Tuesday, July 25, 2006 01:29 PM

The problem could be with your LD_LIBRARY_PATH variable. When strating tomcat there are a lot of paths added.


New path you sould add like:

export LD_LIBRARY_PATH=./lib_c:$LD_LIBRARY_PATH
About | Sitemap | Contact