I’ve been trying to test my web app by starting a Jetty server in the BeforeClass method of my JUnit test case and then using a HttpClient to form request to the server. I get the server to start without any issues, but I keep getting 404’s when I try to make a request.
The configuration of my server is like the following:
public void start() throws Exception {
if (server == null) {
server = new Server(PORT);
server.setStopAtShutdown(true);
wac = new WebAppContext();
wac.setContextPath("/app");
wac.setResourceBase("war");
wac.setClassLoader(this.getClass().getClassLoader());
server.addHandler(wac);
server.start();
}
}
Is there something wrong with my config? The server is running, and I can see that I am hitting it, it just can’t find any resources.
You probably need to define this servlet as a resource in your deployment descriptor (web.xml or jetty-web.xml). Just a guess; a 404 indicates that your code isn’t running at all, and therefore isn’t the problem. The problem is occurring before your code even has a chance to execute.