How do I test RestFul web service with Tomcat?

I created a WebService and chose Web Application > Web Services > Restful Web Services. The project was created with the HelloWorld class.


    public static void main(String[] args) throws IOException {
        HttpServer server = HttpServerFactory.create("http://localhost:9998/");

        System.out.println("Server running");
        System.out.println("Visit: http://localhost:9998/helloworld");
        System.out.println("Hit return to stop...");;
        System.out.println("Stopping server");
        System.out.println("Server stopped");

How do I run this? The Run > Run isn't visibile even after I compile the project? I want to view it at http://localhost:9998.

My second question is how do I make it work with Tomcat on my local machine? I wen to Run > Edit Configuration and specified Tomcat but I can't make it run there either ;(

Please help. The Web services guide for IDEA is very brief and I am a beginner with IDEA. I really appreociate your help. I have been trying to make it work for over 3 hours now.

1 comment
Comment actions Permalink

Hello Flank!

Do you want just to run RESTful web service? Or deploy it under Tomcat? These are two different tasks. I guess you just want to play with your RESTful WS and ensure it works. All you need is just to right-click where is your method main and select Run or Debug in a popup. That's it.
Look at the method main:

    public static void main(String[] args) throws IOException {
        //Here we define end-point (root) of our application
        HttpServer server = HttpServerFactory.create("http://localhost:9998/");

        //And now we start our WS


After you've started your service, you can use Tools -> WebServices -> RESTful Web Services -> Test RESTful Web Service
It allows you to easily call methods marked with @GET, @POST, @DELETE etc..


Please sign in to leave a comment.