我在java bean代码中添加了本机方法。
然后我在System32文件夹中复制了.dll文件。
在JSP中使用javabean。
它给出了一个错误:
HTTP状态500 -
输入例外报告
消息
description服务器遇到内部错误(),导致无法完成此请求。
例外
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: BeanDir.mysimplebean.sayHello()Ljava/lang/String;
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
根本原因
javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: BeanDir.mysimplebean.sayHello()Ljava/lang/String;
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.jsp.callbean_jsp._jspService(callbean_jsp.java:124)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
根本原因
java.lang.UnsatisfiedLinkError: BeanDir.mysimplebean.sayHello()Ljava/lang/String;
BeanDir.mysimplebean.sayHello(Native Method)
org.apache.jsp.jsp.callbean_jsp._jspService(callbean_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
注意Apache Tomcat / 6.0.20日志中提供了根本原因的完整堆栈跟踪。 Apache Tomcat / 6.0.20
Java bean代码:
package BeanDir;
import java.util.*;
//This file must be compiled Manually using javac
//cd D:\tomcat\webapps\examples\WEB-INF\classes\BeanDir\mysimplebean.java
public class mysimplebean
{
static
{
String s=System.getProperty("java.library.path");
System.setProperty("java.library.path",s);
System.loadLibrary("HelloWorld");
}
public String getceoname()
{
String ceonameval = "Tom Hanks CEO of Tom Hanks INC";
return ceonameval;
}
public String ceoemail()
{
String ceoemailval = "tom@tomhanksinc.com";
return ceoemailval;
}
public double findtakehome(int salary,String designation)
{
double takehomeamt;
if(designation=="Developer")
{
takehomeamt = salary+salary*0.15; //15 % Raise in Salary
}
else
{
takehomeamt = salary+salary*0.10; //10 % Raise in Salary
}
return takehomeamt;
}
public native String sayHello();
}
答案 0 :(得分:0)
我不能发表评论,但是......
这两个问题的答案应该是'是'才能使其发挥作用
答案 1 :(得分:0)
嗨,我得到了这篇文章的解决方案。
但不是Java bean。
我在一个类中写了JNI包装器。
我在JSP程序中创建了对象。