报错内容:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Missing resource 'temp/008906_8.xml'
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:500)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
omscq.control.security.TreeMenu.doGet(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
javax.servlet.ServletException: Missing resource 'temp/008906_8.xml'
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.index.tree_jsp._jspService(tree_jsp.java:129)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
omscq.control.security.TreeMenu.doGet(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
javax.servlet.jsp.JspException: Missing resource 'temp/008906_8.xml'
org.apache.taglibs.xsl.ApplyTag.getInputSource(ApplyTag.java:244)
org.apache.taglibs.xsl.ApplyTag.doEndTag(ApplyTag.java:200)
org.apache.jsp.index.tree_jsp._jspService(tree_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
omscq.control.security.TreeMenu.doGet(Unknown Source)
javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.35 logs.
Apache Tomcat/5.5.35
左边的left:
<%@ page contentType="text/html; charset=GBK" errorPage="/index/error.jsp" %>
<html>
<head>
<title>菜单起始页</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body >
正在创建用户菜单…
<script language="javascript">
window.location.href ="treemenu";
</script>
</body>
</html>
Treemenu:
package omscq.control.security;
import com.sict.interaction.InitServlet;
import com.sict.util.HashtableExp;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import omscq.common.security.User;
public class TreeMenu extends HttpServlet
{
public TreeMenu()
{
}
public void init()
throws ServletException
{
}
public void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
{
String s;
InitServlet.initServlet(httpservletrequest);
s = "/index/error.jsp";
User user = (User)httpservletrequest.getSession().getAttribute("userLogin");
String s1 = httpservletrequest.getParameter("funcId") != null ? httpservletrequest.getParameter("funcId") : "8";
if (user != null)
{
String s2 = getServletContext().getRealPath("/");
String s3 = (new StringBuilder()).append("temp/").append(user.getUserId()).append("_").append(s1).append(".xml").toString();
String s4 = (new StringBuilder()).append(s2).append(s3).toString();
File file = new File(s4);
if (!file.exists() || !user.getCreatedXmlFileNames().containsKey(s4))
{
user.createXmlFile(s4, s1);
httpservletrequest.getSession().setAttribute("isCreateNewXmlFile", "false");
}
String s5 = s4.substring(s2.length());
httpservletrequest.setAttribute("xmlFileName", s5);
s = "/index/tree.jsp";
}
System.out.println((new StringBuilder()).append("fileURL==").append(s).toString());
getServletContext().getRequestDispatcher(s).forward(httpservletrequest, httpservletresponse);
break MISSING_BLOCK_LABEL_357;
Exception exception;
exception;
exception.printStackTrace();
System.out.println((new StringBuilder()).append("fileURL==").append(s).toString());
getServletContext().getRequestDispatcher(s).forward(httpservletrequest, httpservletresponse);
break MISSING_BLOCK_LABEL_357;
Exception exception1;
exception1;
System.out.println((new StringBuilder()).append("fileURL==").append(s).toString());
getServletContext().getRequestDispatcher(s).forward(httpservletrequest, httpservletresponse);
throw exception1;
}
public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
{
doGet(httpservletrequest, httpservletresponse);
}
public void destroy()
{
}
}
Tree:
<%@ page contentType="text/html; charset=gb2312"%>
<%@taglib uri="xsltaglibs" prefix="xsl"%>
<%
String xmlFileName = (String)request.getAttribute("xmlFileName");
//xmlFileName = "temp/tree.xml";
//System.out.println("xmlFileName is " + xmlFileName);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/tree.css" rel="stylesheet" type="text/css"/>
<script language="Javascript" src="js/Tree.js"></SCRIPT>
<script language="Javascript" src="js/Context.js"></SCRIPT>
<script language="Javascript" src="js/PopupWindow.js"></SCRIPT>
<script language="javascript">
function exitSystem()
{
if (confirm('确认要退出系统?是否继续?'))
{
openWindow2('userlogout','','toolbar=No, status=No,menubar=no, scrollbars=no,resizable=yes,width='+screen.Width+',height='+screen.height+',left=0,top=0');
window.opener=null;
window.parent.close();
}
else
{
return;
}
}
function showMainFrameSplash(funcId)
{
parent.document.frames['mainFrame'].showSplash('正在加载页面…,请等候!');
parent.document.frames['topright'].location.href="navigater?funcId="+funcId;
}
</script>
</head>
<body onselectstart="return false" bgcolor="#C3D3FD"
style="margin-left:0px;margin-top:0px;">
<div id="folderTree" style="padding-top: 4px;padding-left:0px;" >
<xsl:apply xml="<%=xmlFileName%>" xsl="xsl/menu/Tree.xsl"/>
</div>
<div style="padding-left:6px;cursor: hand; background-image: url(images/line0.gif);" >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle">
<img border="0" src="images/book.gif">
</td>
<td style="padding-left: 3px;font-size:13px;font-color: black;">
<a id="exitSys" onClick="exitSystem();">退出</a>
</td>
</tr>
</table>
</div>
</body>
</html>
1、错误里面有这句话:
omscq.control.security.TreeMenu.doGet(Unknown Source)
找了很久原因没找出问题!
Firefox报错:
在left下这个句话window.location.href ="treemenu"; 是通过servlet找到web.xml中的omscq.control.security.TreeMenu这个class读取的吧!
不知道servlet是否成功!不成功吧,从错误的迹象上看,说treemenu没找到;说成功的吧,通过查看资料和测试都成功了的!
Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>ServletConfigurator</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
<init-param>
<param-name>xmlFile</param-name>
<param-value>WEB-INF/proxool.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!--文档上传-->
<servlet>
<servlet-name>dispmanage</servlet-name>
<servlet-class>omscq.control.upload.DispManage</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispmanage</servlet-name>
<url-pattern>/dispmanage</url-pattern>
</servlet-mapping>
<!---->
***********************************省略
<servlet>
<servlet-name>treemenu</servlet-name>
<servlet-class>omscq.control.security.TreeMenu</servlet-class>
</servlet>
2、错误里面还有这样一句话:org.apache.jasper.JasperException: Missing resource 'temp/008906_8.xml'
这个应该是系统内部的吧!我把url+ temp/008906_8.xml 是找得到源的!
Xml如下:
<?xml version="1.0" encoding="GBK" ?>
- <tree>
- <entity id="8">
<description>OMS</description>
<url>null</url>
<show>true</show>
- <contents>
- <entity id="1100">
<description>调度数据管理</description>
<url>null</url>
<show>true</show>
- <contents>
- <entity id="2005">
<description>基础数据上报</description>
<url>null</url>
<show>false</show>
- <contents>
- <entity id="2032">
<description>一次变数据上报</description>
<url>invokefunction?fid=2032</url>
<show>false</show>
<contents />
</entity>
- <entity id="10001">
<description>二次变数据上报</description>
<url>invokefunction?fid=10001</url>
<show>false</show>
<contents />
</entity>
- <entity id="10000">
<description>数据汇总</description>
<url>invokefunction?fid=10000</url>
<show>false</show>
<contents />
</entity>
- <entity id="2027">
<description>发电厂用电上报</description>
<url>invokefunction?fid=2027</url>
<show>false</show>
<contents />
</entity>
</contents>
</entity>
- <entity id="9946">
<description>调度报表</description>
<url>null</url>
<show>false</show>
- <contents>
- <entity id="9959">
<description>供电量日报表</description>
<url>invokefunction?fid=9959</url>
<show>false</show>
<contents />
</entity>
- <entity id="9958">
<description>电量周报</description>
<url>invokefunction?fid=9958</url>
<show>false</show>
<contents />
</entity>
- <entity id="9957">
<description>电厂电量月报</description>
<url>invokefunction?fid=9957</url>
<show>false</show>
<contents />
</entity>
</contents>
</entity>
</contents>
</entity>
- <entity id="1000">
<description>调度专业管理</description>
<url>null</url>
<show>true</show>
- <contents>
- <entity id="1200">
<description>调度日常管理</description>
<url>null</url>
<show>false</show>
- <contents>
- <entity id="9765">
<description>运行日志</description>
<url>invokefunction?fid=9765</url>
<show>false</show>
<contents />
</entity>
- <entity id="1215">
<description>交接班管理</description>
<url>invokefunction?fid=1215</url>
<show>false</show>
<contents />
</entity>
- <entity id="10010">
<description>实绩评定</description>
<url>invokefunction?fid=10010</url>
<show>false</show>
<contents />
</entity>
</contents>
</entity>
- <entity id="1900">
<description>事故跳闸记录</description>
<url>null</url>
<show>false</show>
- <contents>
- <entity id="9961">
<description>事故跳闸记录</description>
<url>invokefunction?fid=9961</url>
<show>false</show>
<contents />
</entity>
- <entity id="9960">
<description>事故跳闸统计</description>
<url>invokefunction?fid=9960</url>
<show>false</show>
<contents />
</entity>
</contents>
</entity>
- <entity id="1440">
<description>检修工作票管理</description>
<url>null</url>
<show>false</show>
- <contents>
- <entity id="10008">
<description>检修工作票执行</description>
<url>invokefunction?fid=10008</url>
<show>false</show>
<contents />
</entity>
- <entity id="10009">
<description>检修工作票查询</description>
<url>invokefunction?fid=10009</url>
<show>false</show>
<contents />
</entity>
</contents>
</entity>
</contents>
</entity>
</contents>
</entity>
</tree>
我觉得你这样手动查找资源是可以找到,但是可能是你的XML文件配置出错了,导致tomcat无法查找到资源项,你还是仔细查找下TreeMenu.doGet()方法中的代码是否有错误或者不规范的地方,详细的测试下吧!
.xml 文件出错几率很小,因为这个项目之前在用,之前在linux平台,先在window平台而已
这个问题是错在查找文件(008906_8.xml)的时候,路径出错,建议打印出相关的路径,就可以找出bug了..
看了一下代码:
1 String s2 = getServletContext().getRealPath("/"); 2 String s3 = (new StringBuilder()).append("temp/").append(user.getUserId()).append("_").append(s1).append(".xml").toString(); 3 String s4 = (new StringBuilder()).append(s2).append(s3).toString(); 4 File file = new File(s4);
这几个是bug的关键...
大家可以一起交流:hongtenzone@foxmail.com
这个路径问题,我也查多,没什么问题!这样这个项目这块我分离出来了,我给你omscq,帮调试下,我的确找不到原因了。
@seen8com:
1.还有个方法,就是把路径修改一下,再做测试...
2.如果不行的话,看一下你的路线下面有没有这个008906_8.xml文件,如果有的话,使用他的绝对路径