概述
基于Tomcat服务器进行web应用的开发,初学者经常会犯一些错误,一下罗列了常见的错误及解决方法.
一. 应用下面(WEB-INF/lib)导入了与Tomcat 自带的jar(%CATALINA_HOME%/lib) 想同的包,如:el-api.jar, jsp-api.jar 时,启动服务器,然后发送请求会报如下异常
1. jsp-api.jar 会引起NullPointer 异常,发生于jsp所对应java 类(%CATALINA_HOME%/work/Catalina/localhost/xxx)的方法中
public void _jspInit() {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
_jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
}
2. el-api.jar 会引起
javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/WEB_002dINF/jsp/hello_jsp, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature
所以当出现这两种情况时,只需要将应用中的这两个jar包删除就行了
最后
以上就是如意宝马为你收集整理的Tomcat 部署常见问题的全部内容,希望文章能够帮你解决Tomcat 部署常见问题所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复