java.lang.UnsatisfiedLinkError when run on process() method
[nobr]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 codefor JNIWrapper and servlet file
JNIWrapper.java
publicclass JNIWrapper{
<br>
static{
System.loadLibrary("CalcCore");
}
<br>
publicnativeboolean initApi();
<br>
publicnative String createPolicy(String s);
<br>publicnative String doIllustration(int h, String s);
<br>
publicnativevoid uninitApi();
<br>
public JNIWrapper(){
}
<br>
public String CreatePolicy(String xmlInput){
return createPolicy(xmlInput);
}
<br>
public String DoIllustration(int handle){
return doIllustration(handle,"");
}
<br>
protectedvoid finalize(){
uninitApi();
}
<br>
}
JNLProds.java (with doGet() method)
publicclass JNLProdsextends HttpServlet{
publicvoid doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
JNIWrapper jni =new JNIWrapper();<br>
jni.CreatePolicy("abc");<br>
}
}
JNLProds.java (with process() method)
publicclass JNLProdsextends HttpServletimplements ActionServlet, UIConstants{
publicvoid process (ActionContext context, HttpServletRequest req, HttpServletResponse res)throws UIException{
JNIWrapper jni =new JNIWrapper();<br>
jni.CreatePolicy("abc");<br>
}
}
this is the c++ source code that using JNInative method
#include"JNIWrapper.h"
JNIEXPORT jboolean JNICALL Java_JNLTermCalcEngine_initApi
(JNIEnv *env, jobject obj){
<br>
char l_DataPath[30] ="C:\\Jackson\\Life\\Data\\";<br>
illBase::SetDataPath(l_DataPath);<br>
return DllInit();<br>
}
JNIEXPORT jstring JNICALL Java_JNLTermCalcEngine_createPolicy
(JNIEnv *env, jobject obj, jstring nString){
jboolean isCopy =true;<br>
string inString ="";<br>
string tmpStr ="xyz";<br>
const char* pInString = NULL;<br>
pInString = env->GetStringUTFChars(nString, &isCopy);<br>
inString.insert(0,pInString);<br>
if(isCopy == JNI_TRUE)
env->ReleaseStringUTFChars(nString,(const char*) inString.c_str());<br>
return (jstring) env->NewStringUTF((const char*) tmpStr.c_str());<br>
}
JNIEXPORT jstring JNICALL Java_JNLTermCalcEngine_doIllustration
(JNIEnv *env, jobject obj, jint iHandler, jstring nString){
jboolean isCopy =true;<br>
string inString ="";<br>
string outString ="";<br>
string tmpString ="1234";<br>
inString.insert(0,env->GetStringUTFChars(nString, &isCopy));<br>
if(isCopy == JNI_TRUE)
env->ReleaseStringUTFChars(nString,NULL);
return (jstring) env->NewStringUTF((const char*) tmpString.c_str());<br>
}
JNIEXPORTvoid JNICALL Java_JNLTermCalcEngine_uninitApi
(JNIEnv *env, jobject obj){
DllUninit();<br>
}
FYI, i put my"CalcCore.dll" which is compiled in c++ in JAVA_HOME\bin directory and all my JNIWrapper.class and JNLProds.class in CATALINA_HOME\webapps\jni\WEB-INF\classes
folder and my jsp file in CATALINA_HOME\webapps\jni\jsp 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
[/nobr]

