Я реализовал сервлет, размещенный на сервере Tomcat 6 в Mandriva Linux. Я смог заставить клиента общаться с сервлетом. В ответ на запрос сервлет пытается создать экземпляр другого класса (с именем KalmanFilter), расположенного в том же каталоге. KalmanFilter пытается создать четыре матрицы (используя пакет Jama Matrix). Но на этом этапе Servlet останавливается без каких-либо исключений!
Однако из другого тестового кода в том же каталоге я смог создать экземпляр класса KalmanFilter и продолжить работу без ошибок. Проблема возникает только тогда, когда мой сервлет пытается создать экземпляр класса KalmanFilter и создать матрицы. Любая идея?
Ниже приведены коды:
MyServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class MyServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
doGet(request, response);
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException{
PrintWriter out = null; //response.getWriter();
try{
System.out.println("creating new KalmanFilter");
KalmanFilter filter = new KalmanFilter();
out = response.getWriter();
out.print("filter created");
}catch(Exception ex){
ex.printStackTrace();
System.out.println("Exception in doGet(): " + ex.getMessage());
ex.printStackTrace(out);
}
}
}
KalmanFilter.java
import Jama.Matrix;
public class KalmanFilter {
protected Matrix X, X0;
protected Matrix F, Q;
//protected Matrix F, B, U, Q;
protected Matrix H, R;
protected Matrix P, P0;
private final double EPSILON = 0.001;
public KalmanFilter(){
System.out.println("from constructor of KalmanFilter");
createInitialMatrices();
}
private void createInitialMatrices(){
System.out.println("from KalmanFilter.createInitialMatrices()");
double[][] pVals = {
{1.0, 0.0},
{0.0, 1.0}
};
double[][] qVals = {
{EPSILON, EPSILON},
{EPSILON, EPSILON}
};
double[][] hVals = {
{1.0, 0.0},
{0.0, 1.0},
{1.0, 0.0},
{0.0, 1.0}
};
double[][] xVals = {
{0.0},
{0.0},
};
System.out.println("creating P Q H X matrices in createInitialMatrices()");
try{
this.P = new Matrix(pVals);
System.out.println("created P matrix in createInitialMatrices()");
this.Q = new Matrix(qVals);
System.out.println("created Q matrix in createInitialMatrices()");
this.H = new Matrix(hVals);
System.out.println("created H matrix in createInitialMatrices()");
this.X = new Matrix(xVals);
System.out.println("created X matrix in createInitialMatrices()");
System.out.println("created P Q H X matrices in createInitialMatrices()");
}catch(Exception e){
System.out.println("Exception from createInitialMatrices()"+ e.getMessage());
e.printStackTrace();
}
System.out.println("returning from createInitialMatrices()");
}
}