1
votes

I'm experimenting with Junit 4 it's been a while now. Part of my unit testing requires deploying a war application that exposes some web services. I'm using Eclipse Helios, and I've added two different jars to my project's build path which are: 1- jetty-all-8.1.3.v20120416.jar 2- servlet-api-3.0.jar

Now in my test class, I'm running the following code in order to start jetty and in order to deploy my axis2.war webapp that contains my exposed web services:

System.out.println("Initializing server");
       Server server = new Server(8181);
       System.out.println("Server initialized");

        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath("/");
        webapp.setParentLoaderPriority(true);
        webapp.setWar("C:\\axis2.war")

        server.setHandler(webapp);

        System.out.println("Starting server");
        server.start();

        System.out.println("Joining server");

        server.join();
        System.out.println("Finished starting Jetty...");

The output of the above code is as follows:

Server initialized
Starting server
Joining server

Trying to join the server is running indefinitely and it doesn't throw any exceptions whatsoever.

In another attempt, I have downloaded jetty 8.1.3 web server on my machine, and placed the axis.war under the webapps directory, and then started jetty using the start.jar from the command line. It worked perfectly from there, and I was able to reach my exposed web service methods.

However, I need to be able to start and stop jetty programmatically and deploy my web application programmatically as well. Could anyone tell me what could the problem be?

Thanks in advance.

1
Why join in the first place??? stackoverflow.com/questions/15924874/…AlikElzin-kilaka

1 Answers