2017-07-26 3 views
0

VM(ubuntu 14)に私のSpringプロジェクトをデプロイしています.Ajax呼び出しを実行するボタンを使用すると、スタック内でerror500が返されます。NoSuchElementExceptionはイテレータをポイントしています。NoSuchElementExceptionを伴うエラー500

日食の私のアプリの作業罰金と私のVMに展開するときにも、私はクライアントコンピュータにVM(すべての作業罰金)をエクスポートしたが、それでもここでエラーに500

を与えるトレースです。私は同じVMを使用しますが、クライアントにしていたときに

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コードを使用して、その何かを考えていけない、バグがありますコンピュータ、ajax呼び出しが失敗し、次のエラーが発生します。

ここ

は、AJAX呼び出しです:

<%@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(); 
%> 

私はアヤックスが行ったことを意味する「私は印刷を比較しています」が見つかりログをチェックしています:

 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ページですto 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) { 

     } 
    } 
} 
} 

すべてのアイデアは、このエラーは、私が知っているすべてのフォーラムやウェブサイトを検索から来たが、無駄にすることができました。

感謝します。

+0

得るために何の次の要素がない場合あなたの 'compare'コードは、')( 'it.nextを呼び出しています。 –

+0

はい、トレースが何を言っているのですが、コードがeclipseで正常に動作していて、自分のコンピュータ上のVMでエラーが発生したのは、クライアントマシン上でVMを使用しているとき(同じVM、クライアントコンピュータ)。 –

答えて