2011-03-20 114 views
3

我正在嘗試使用Grizzly作爲Web容器的球衣教程的第一部分。我只是在「Hello World!」部分,並試圖運行我的代碼。這是我嘗試部署的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) 

有誰知道發生了什麼事?我確定我的包裹都是正確的。我不知道如何配置灰熊,只是想學習如何在年底使用澤西

回答

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

/;你錯過了它。