在编辑我的代码以使用JNI之后,我在JSP上获得了NoClassDefFoundError
。当我在.java and .class
路径中拥有WEB-INF/classes/matrixcalculator
时,我似乎无法理解为什么。 .h, .c and .so
位于WEB-INF/classes/
文件夹旁边的matrixcalculator
。这是代码错误日志:
java.lang.NoClassDefFoundError: Could not initialize class matrixcalculator.MatrixCalculator
org.apache.jsp.adminOnly_jsp._jspService(adminOnly_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:750)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:720)
org.apache.jsp.requestPermission_jsp._jspService(requestPermission_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
它之前正在工作但是在刚添加本机函数,loadLibrary和其他文件之后,我收到此错误。我尝试将文件更改为WEB-INF/classes/matrixcalculator
中的相同文件夹,仍然无法摆脱错误。我相信它与导出MatrixCalculator.class所在的路径有关,但我真的无法理解它在哪里以及为什么。除非我把他的文件放在Tomcat的公共文件夹中,但我可能是错的。我也直接调用JSP,而不是使用Tomcat管理器
我添加了language = "java"
,我在java bean中遇到错误:
org.apache.jasper.JasperException: An exception occurred processing JSP page /adminOnly.jsp at line 8
5: - %> 6: 7:<%@ page language =“java”contentType =“text / html”pageEncoding =“UTF-8”%> 8: 9: 10: 11:
这是静态块:
static {
System.loadLibrary("methodsViaC");
}
添加try / catch(例外e)后NEW ERROR:
java.lang.UnsatisfiedLinkError: no methodsViaC in java.library.path
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
java.lang.Runtime.loadLibrary0(Runtime.java:849)
java.lang.System.loadLibrary(System.java:1088)
matrixcalculator.MatrixCalculator.<clinit>(MatrixCalculator.java:77)
org.apache.jsp.adminOnly_jsp._jspService(adminOnly_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:750)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:720)
org.apache.jsp.requestPermission_jsp._jspService(requestPermission_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
但如果我刷新页面,我会收到第一个错误。
答案 0 :(得分:0)
此错误表示该类无法初始化,但并不意味着无法找到它。所以,我的建议是在matrixcalculator.MatrixCalculator类中检查静态变量和静态初始化块。看起来在静态块中抛出了未捕获的异常。