我在虚拟机(ubuntu 14)上部署我的春天项目,当我使用执行ajax调用的按钮时,它给出了错误500与堆栈NoSuchElementException指向一个迭代器。在Eclipse上错误500与NoSuchElementException
我的应用程序做工精细,并在我的虚拟机部署的时候,所以我导出的VM(所有做工精细)到客户端计算机,但仍然给错误500
这里是跟踪:
HTTP Status 500 - An exception occurred processing JSP page /executeComparison.jsp at line 7
type Exception report
message An exception occurred processing JSP page /executeComparison.jsp at
line 7
description The server encountered an internal error that prevented it from
fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page
/executeComparison.jsp at line 7
4:
5: <%
6: System.out.println("I'm comparing");
7: ComputeDifference.printDiffs(ComputeDifference.getAllDiffs("P1", "P2"));
8: String data = "active";
9: out.print(data);
10: out.flush();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
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.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.util.NoSuchElementException
java.util.ArrayList$Itr.next(ArrayList.java:834)
comparator.ComputeDifference.compare(ComputeDifference.java:212)
comparator.ComputeDifference.getAllDiffs(ComputeDifference.java:29)
org.apache.jsp.executeComparison_jsp._jspService(executeComparison_jsp.java:70)
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.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache
Tomcat/7.0.53 logs.
Apache Tomcat/7.0.53
我不认为它与迭代器或看到它的做工精细的日食,并在我的VM在我的电脑中的Java代码什么的,错误是那里当我使用相同的VM,但是,客户端电脑,阿贾克斯调用失败,并给出以下错误
jquery-1.11.0.min.js:4 GET
https://193.169.100.12:8443/DMX.v.3.10/executeComparison.jsp?
rand=0.9844812755765802 500 (Internal Server Error)
这里是Ajax调用:
function evaluateDelta() {
var rand = Math.random();
$.ajax({
url: "executeComparison.jsp",
dataType: 'text',
data: { rand: rand },
success: function (data) {
console.log("got the difference");
displayDelta();
}
});
}
这里是jsp页面:
<%@page import="java.util.*"%>
<%@page import="comparator.ComputeDifference"%>
<%
System.out.println("I'm comparing");
ComputeDifference.printDiffs(ComputeDifference.getAllDiffs("P1", "P2"));
String data = "active";
out.print(data);
out.flush();
%>
当我检查日志,我发现“我比较印”,这意味着阿贾克斯去到jsp但jsp在下一行失败,如堆栈跟踪所示。
最后,这里是迭代器指向堆栈的函数(syso中的一个“System.out.println(”\ r \ n \ r \ n ----------- - 命令 “+ it.next()+” \ r \ n \ r \ n “);”:
static public void compare (String fileName1,String fileName2) throws IOException{
String filePath1="C:/Users/Mike/Desktop/"+fileName1+".txt";
String filePath2="C:/Users/Mike/Desktop/"+fileName2+".txt";
BufferedReader in = null;
BufferedReader inN=null;
BufferedReader in2=null;
BufferedReader in2N=null;
String line = "", line2= "";
ArrayList<String> commands=ComputeDifference.getCommands(filePath1);
Iterator<String> it = commands.iterator();
boolean command=true;
try {
in = new BufferedReader(new FileReader(filePath1));
inN = new BufferedReader(new FileReader(filePath1)); inN.readLine();
in2= new BufferedReader(new FileReader(filePath2));
in2N= new BufferedReader(new FileReader(filePath2)); in2N.readLine();
File file = new File("C:/Users/Mike/Desktop/command1.txt");
File file1 = new File("C:/Users/Mike/Desktop/command2.txt");
File fileDiff = new File("C:/Users/Mike/Desktop/commandDiff.txt");
PrintStream printStreamToFile = new PrintStream(file);
PrintStream printStreamToFile1 = new PrintStream(file1);
PrintStream printStreamToFileDiff = new PrintStream(fileDiff);
int i=0;
while ((line = in.readLine()) != null) {
String next=inN.readLine();
System.setOut(printStreamToFile);
System.out.println(line);
if(next != null && next.contains("#")){
command=true;
while (command == true && (line2 = in2.readLine()) != null) {
String next2=in2N.readLine();
System.setOut(printStreamToFile1);
System.out.println(line2);
if(next2 != null && next2.contains("#")){
System.setOut(printStreamToFileDiff);
if(i!=0){
System.out.println("\r\n\r\n------------ Command "+it.next()+"\r\n\r\n");
List<String> original = fileToLines("command1");
List<String> revised = fileToLines("command2");
System.setOut(printStreamToFileDiff);
Patch<String> patch = DiffUtils.diff(original, revised);
for (Delta<String> delta: patch.getDeltas()) {
System.setOut(printStreamToFileDiff);
System.out.println(delta);
}
}
else{
i++;
it.next();
}
printStreamToFile1.close();
file1.delete();
file1.createNewFile();
printStreamToFile1=new PrintStream(file1);
command=false;
}
}
printStreamToFile.close();
file.delete();
file.createNewFile();
printStreamToFile=new PrintStream(file);
}
}
System.setOut(ApplicationConstant.console);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
if (in2 != null) {
try {
in2.close();
} catch (IOException e) {
}
}
}
}
任何想法是这个错误,但是来自我找遍了所有论坛和网站,我知道白白。
非常感谢。
你'compare'代码调用'it.next()'当没有下一个元素得到。 –
是这就是跟踪说的,但代码在eclipse和我的计算机上我的虚拟机工作正常,只有当我在客户端计算机上使用我的虚拟机时生成错误(同一虚拟机,从virtualbox导出,然后导入客户端计算机)。 –