【问题标题】:Following Jersey Tutorial跟随泽西教程
【发布时间】:2011-03-20 02:43:00
【问题描述】:

我正在尝试使用 Grizzly 作为 Web 容器来遵循球衣教程的第一部分。我只是在 "Hello World!" 部分并尝试运行我的代码。这是我尝试部署的主要网络服务。

    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);
    }
}

当我运行它时,我总是得到

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)

有人知道发生了什么吗?我确保我的包裹都是正确的。我不知道如何配置 grizzly,只是想学习如何使用 Jersey

【问题讨论】:

    标签: java jersey jax-rs grizzly


    【解决方案1】:
     final String baseUri = "http://localhost:9998/";
    

    注意最后的/;你错过了它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-06
      • 1970-01-01
      • 1970-01-01
      • 2013-07-21
      • 2017-01-26
      相关资源
      最近更新 更多