JSP 调用JNI 出错 java.lang.UnsatisfiedLinkError
我采用的是 通过VC++写低层程序生成DLL文件,然后通过JNI进行调用,
但是在Eclipse下 JAVA程序能够成功调用,但是通过JSP就不能调用,出现下面的错误:
org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.UnsatisfiedLinkError: test
at cn.Test.test(Native Method)
at org.apache.jsp.AdminGUI.core.equipment.boxinspect_jsp._jspService(boxinspect_jsp.java:125)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
2009-6-2 17:13:40 org.apache.catalina.core.StandardHostValve throwable
警告: Exception Processing ErrorPage[exceptionType=java.lang.Exception, location=/exception.jsp]
ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error
有高手知道这是怎么回事吗?如果说是DLL文件调用不正确的话,那为什么JAVA程序能够调用,JSP不能调用呢?
DLL文件所在的目录已经加入环境变量了,而且也把DLL文件放进system32里的。
环境:Eclipse VC++2006 附程序:
VC++:
javatest.cpp:
#include "cn_Test.h"
#include <iostream.h>
JNIEXPORT void JNICALL Java_cn_Test_test(JNIEnv * env, jobject obj)
{
cout<<"HELLO"<<endl;
}
cn_Test.h:
#include "jni.h"
#ifndef _Included_cn_Test
#define _Included_cn_Test
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: cn_Test
* Method: test
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_cn_Test_test
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
JAVA:
javatest.java:
package cn;
public class Test {
public native void test();
public static void main(String[] args) {
// TODO 自动生成方法存根
System.loadLibrary("javatest");
Test tst =new Test();
tst.test();
}
}
1.jsp:
<%@page import="cn.Test"%>
<%
System.loadLibrary("javatest");
Test tst1 =new Test();
tst1.test();
%>