2013-09-11 25 views
0

我无法运行我的RESTful服务与嵌入式Jetty 7和泽西岛。当我打电话给我的简单的hello测试,我得到:新泽西州与码头艰难时间

javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message 
body writer for  Java class java.lang.String, and Java type class java.lang.String, 
and MIME media type text/plain was not found 

我在这里看到张贴在如此相似的错误,但它是自定义类的,而我是刚刚String。任何提示?我初始化服务器代码:

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); 
    context.setContextPath("/"); 
    server.setHandler(context); 
    ServletContainer container = new ServletContainer(); 
    ServletHolder h = new ServletHolder(container); 
    h.setInitParameter("com.sun.jersey.config.property.packages", "api"); 
    context.addServlet(h, "/res/*"); 

而且dependances:

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-server</artifactId> 
    <version>1.11.1</version> 
</dependency> 
<dependency> 
       <groupId>org.eclipse.jetty</groupId> 
       <artifactId>jetty-server</artifactId> 
       <version>7.1.6.v20100715</version> 
</dependency> 

你有什么提示吗?

回答

0

交易所jersey-server到:

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-bundle</artifactId> 
    <version>1.11.1</version> 
</dependency>