tomcat的参考问题?

时间:2009-06-12 13:53:25

标签: java jsp tomcat log4j

我遇到tomcat问题,如果我尝试部署代码,我会收到以下错误:

  

堆栈跟踪:     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

     

根本原因

     

org.apache.jasper.JasperException:   无法编译JSP的类

     

生成的servlet错误:只有一个类型   可以导入。   org.apache.log4j.Logger解析为   封装

     

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)     org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)     org.apache.jsp.secpay_jsp._jspService(secpay_jsp.java:78)     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

     

根本原因

     

org.apache.jasper.JasperException:   无法编译JSP的类

     

生成的servlet错误:只有一个类型   可以导入。   org.apache.log4j.Logger解析为   封装

     

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)     org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)     org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)     org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)     org.apache.jsp.secpay_jsp._jspService(secpay_jsp.java:78)     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

我认为在某处加载log4j存在问题,但我不确定在哪里加载它。我在哪里添加一个将log4j添加到部署的引用?

更新

以下是至少打破类似异常的代码示例

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="org.apache.log4j.Logger"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
hello world

</body>
</html> 

如果你找到对org.apache.log4j的引用,页面只显示hello world ......

2 个答案:

答案 0 :(得分:1)

您需要在WEB-INF / lib目录或tomcat / lib目录中安装log4j - * .jar。

答案 1 :(得分:-1)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

当 - &gt;时出现此错误服务(ServletHttpRequest rq,ServletHttpResponse rs)抛出Exp ... on没有在类中定义..

所以你需要用First Service实现你的代码....(方法),在它重定向(req,res)到doPost(...)后,你将得到你的解决方案..