Question

I am trying to follow the first part of jersey tutorial using Grizzly as the web container. I am just at the "Hello World!" part and trying to run my code. This is the main of the web services that I am trying to deploy.

    public class Main {

    public static void main(String [] args) throws IOException {
        final String baseUri = "http://localhost:9998";
        final Map<String, String > initParams = new HashMap<String, String>();


        initParams.put("com.sun.jersey.config.property.packages", "com.sun.ws.rest.samples.helloworld.resources");

        System.out.println("Starting grizzly");
        SelectorThread threadSelector = GrizzlyWebContainerFactory.create(baseUri,initParams);

        System.out.println(String.format("Jersey app started with WADL available at %sapplication.wadl Try out %shelloworld. Hit enter to stop it...", baseUri, baseUri));

        System.in.read();
        threadSelector.stopEndpoint();
        System.exit(0);
    }
}

When I run this, I always get

Exception in thread "main" java.lang.IllegalArgumentException: The URI path, of the URI http://localhost:9998, must be present
at com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory.create(GrizzlyWebContainerFactory.java:236)
at com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory.create(GrizzlyWebContainerFactory.java:138)
at com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory.create(GrizzlyWebContainerFactory.java:105)
at Main.main(Main.java:29)

Does anyone know what is happening? I have made sure that my packages are all correct. I do not know how to configure grizzly and just trying to learn how to use Jersey

Was it helpful?

Solution

 final String baseUri = "http://localhost:9998/";

Note the / on the end; you're missing it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top