Servlet stops without giving any exception
Posted
by Fahim
on Stack Overflow
See other posts from Stack Overflow
or by Fahim
Published on 2010-04-04T20:25:38Z
Indexed on
2010/04/04
20:33 UTC
Read the original article
Hit count: 412
Hi, I have implemented a Servlet hosted on Tomcat 6 server on Mandriva Linux. I have been able to make the client communicate with the Servlet. In response to a request the Servlet tries to instantiate a another class (named KalmanFilter) located in the same directory. The KalmanFilter tries to create four Matrices (using Jama Matrix package). But at this point Servlet stops without giving any exception !
However, from another test code in the same directory I have been able to create instance of KalmanFilter class, and proceed without any error. The problem occurs only when my Servlet tries to instantiate the KalmanFilter class and create the matrices. Any idea?
Below are the codes:
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()");
}
}
© Stack Overflow or respective owner