我在虛擬機(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導出,然後導入客戶端計算機)。 –