English 中文(简体)
MIME 媒体类型应用程序/ xml 未在命令行中找到, 但在 Eclipse 中工作
原标题:MIME media type application/xml was not found in command line, but work in Eclipse
  • 时间:2012-05-23 04:26:54
  •  标签:
  • java
  • jersey

我使用马文、泽西和杰蒂服务器 建立一个网络服务界面

当我在日光上开发和测试软件时,一切都很好。然而,当我试图部署项目并向接口提出请求时,服务器报告说,“找不到MIME媒体类型应用程序/xml”。

我试图在几天内找出问题,发现(由泽西岛提供的)ServiceFinder(由泽西岛提供)可以在Eclipse上找到所有信件BodyWriter, 但不在命令线上。 我还检查了所有热量自由已经到位, 并在META- INF 中定义。

任何帮助都是感激不尽的!

JDK: 1.6.0_30 Eclipse: Indigo SR2 Jersey: 1.12 Jetty: 6.1.25

服务源代码 :

ServiceFinder.find(javax.ws.rs.ext.MessageBodyWriter.class, true).toClassArray();

=============== META-INF Created-By: Apache Maven Built-By: Build-Jdk: 1.6.0_30 Class-Path: jersey-servlet-1.12.jar jersey-server-1.12.jar asm-3.1.jar jersey-core-1.12.jar

在命令行( 仅可查看MessageBodyWriter 可用)

GN MBR:class com.sun.jersey.server.impl.template.ViewableMessageBodyWriter CP:co
m.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@28946
139 C:com.sun.jersey.server.impl.template.ViewableMessageBodyWriter@6a7d46b8

日食(所有球衣供应商均提供衣物)

GN MBR:class com.sun.jersey.server.impl.template.ViewableMessageBodyWriter CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@2fba32e3 C:com.sun.jersey.server.impl.template.ViewableMessageBodyWriter@60039882
GN MBR:class com.sun.jersey.core.impl.provider.entity.StringProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@6962ed8f C:com.sun.jersey.core.impl.provider.entity.StringProvider@31cc3e7c
GN MBR:class com.sun.jersey.core.impl.provider.entity.ByteArrayProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@5dda7d56 C:com.sun.jersey.core.impl.provider.entity.ByteArrayProvider@1af30c34
GN MBR:class com.sun.jersey.core.impl.provider.entity.FileProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@335ac93d C:com.sun.jersey.core.impl.provider.entity.FileProvider@6695c13b
GN MBR:class com.sun.jersey.core.impl.provider.entity.InputStreamProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@d51de22 C:com.sun.jersey.core.impl.provider.entity.InputStreamProvider@4592b04e
GN MBR:class com.sun.jersey.core.impl.provider.entity.DataSourceProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@79ce9102 C:com.sun.jersey.core.impl.provider.entity.DataSourceProvider@41fb404
GN MBR:class com.sun.jersey.core.impl.provider.entity.RenderedImageProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@689258c7 C:com.sun.jersey.core.impl.provider.entity.RenderedImageProvider@4c843d2b
GN MBR:class com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@6002a673 C:com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider@20f1fbb4
GN MBR:class com.sun.jersey.core.impl.provider.entity.FormProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@4dfdf943 C:com.sun.jersey.core.impl.provider.entity.FormProvider@44d0d6fd
GN MBR:class com.sun.jersey.core.impl.provider.entity.FormMultivaluedMapProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@5cf7c5b5 C:com.sun.jersey.core.impl.provider.entity.FormMultivaluedMapProvider@29dafde4
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@ed51dc2 C:com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App@8c5697a
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@4994b329 C:com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text@48e14b1f
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@417e6e7c C:com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General@6c9ce1cb
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@5387b07b C:com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App@2acb4dcf
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@71538614 C:com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text@59b02f33
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@2287c52c C:com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General@9fc1ec5
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@7fa1dd69 C:com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App@7a95626d
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@5bcf59f5 C:com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text@1e69555f
GN MBR:class com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@a1b12ea C:com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General@4feaf536
GN MBR:class com.sun.jersey.core.impl.provider.entity.ReaderProvider CP:com.sun.jersey.core.spi.component.ProviderFactory$SingletonComponentProvider@7776c5d4 C:com.sun.jersey.core.impl.provider.entity.ReaderProvider@5d66341b

.

完整错误堆疊 {}

23-May-2012 12:05:54 com.sun.jersey.spi.container.ContainerResponse write
SEVERE: The registered message body writers compatible with the MIME media type
are:
*/* ->
  com.sun.jersey.server.impl.template.ViewableMessageBodyWriter

23-May-2012 12:05:54 com.sun.jersey.spi.container.ContainerResponse logException

SEVERE: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException: A message body writer for Java class com.test.TestRest, and Java type class com.test.TestRest, and MIME media type application/xml was not found
        at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:285)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1451)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
        at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
        at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
        at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class com.test.TestRest, and Java type class com.test.TestRest, and MIME media type application
/xml was not found
        . 21 more

============= Start Jetty Server ==== I am using Jetty Web Server, and started the server like this:

Context root = new Context(server, "/", Context.SESSIONS); 
// Add REST handlers and Singleton providers 
ResourceConfig rc = new PackagesResourceConfig("handlerpkg"); 

// Add the Jersey root servlet holder to the root context 
root.addServlet(new ServletHolder(new ServletContainer(rc)), "/*");

server.start();
最佳回答

这个问题的解决方式是,在舱道中明确增加球衣核心-1.12.jar,作为VM论点的一部分。

我当时只有一个图书馆在 - cp 中, 它指向使用 ANIFEST. MF 文件中的类Paths 字段的其他图书馆。 有趣的是, 使用这个方法, 服务员可以找到 messageBodyReader, 但不能找到 MessageBodyWriter 。

现在,我有两个图书馆在 -cp, 这是球衣核心-1.12jar 和 lib 包含主班。

谢谢你的大力帮助 堆积流是一个惊人的开发者网站

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签