我正在尝试使用Grizzly作为Web容器来遵循泽西教程的第一部分.我只是在“你好世界!”部分并尝试运行我的代码.这是我尝试部署的Web服务的主要部分.
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)
有谁知道发生了什么?我确保我的包裹都是正确的.我不知道如何配置灰熊,只是想学习如何使用泽西
解决方法:
final String baseUri = "http://localhost:9998/";
注意/在最后;你错过了.