Next Jersey Guide

I am trying to complete the first part of a knitwear tutorial using Grizzly as a web container. I'm just on "Hello world!". and try to run my code. This is the bulk of the web services I'm 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 going on? I made sure my packages are correct. I don’t know how to set up a grizzly and just try to learn how to use a jersey.

+3
source share
1 answer
 final String baseUri = "http://localhost:9998/";

Pay attention to /the end; you are lacking.

+8
source

All Articles