Jetty 7 と Jersey が組み込まれた RESTful サービスを実行できません。簡単な 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
SO に投稿された同様のエラーを見ましたが、それはカスタム クラス用であり、私のものは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/*");
そして依存関係:
<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>
ヒントはありますか?