没有找到Java类…和MIME媒体类型text / html的消息体编写器

栏目: Html · 发布时间: 6年前

内容简介:参见英文答案 >我正在使用jms /气氛框架在两个应用程序之间进行通信.其中一个应用是主题的消息生成器,发送以下类型的自定义对象:

参见英文答案 > How to produce JSON output with Jersey 1.6 using JAXB 6

我正在使用jms /气氛框架在两个应用程序之间进行通信.

其中一个应用是主题的消息生成器,发送以下类型的自定义对象:

@XmlRootElement
    public class A implements Serializable{
    public A(){}

    /* some private properties */

   }

另一方面,不止一个消费者正在倾听主题,并根据身份认证不同订阅.

@GET
    @Produces({MediaType.APPLICATION_JSON})
    public SuspendResponse<A> subscribe() {
    return new SuspendResponse.SuspendResponseBuilder<A>()
            .broadcaster(topic)
            .outputComments(true)
            .addListener(new EventsLogger()).build();
    } 
   @Override
public void incomingBroadcast() {
    try {
        String id = getID();
        if (id.startsWith("/*")) {
            id = "atmosphere";
        }

        logger.info("Looking up Connection Factory {}", FACTORY_NAME);
        Context ctx = new InitialContext();
        ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(FACTORY_NAME);

        logger.info("Looking up topic: {}", TOPIC_NAME);
        Topic topic = (Topic) ctx.lookup(TOPIC_NAME);

        connection = connectionFactory.createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        logger.info("Create consumer for : {}", id);
        String selector = String.format("BroadcasterId = '%s'", id);

        consumer = session.createConsumer(topic, selector);
        consumer.setMessageListener(new MessageListener() {

            @Override
            public void onMessage(Message msg) {
                try {
                    ObjectMessage om = (ObjectMessage) msg;
                    A a = (A) om.getObject();
                    if (a!= null && bc != null) {
                        broadcastReceivedMessage(a);
                    }
                    logger.info("Broadcasted message: {} ", a);
                } catch (JMSException ex) {
                    logger.warn("Failed to broadcast message", ex);
                }
            }
        });
        publisher = session.createProducer(topic);
        connection.start();
        logger.info("JMS created for topic {}, with filter {}", TOPIC_NAME, selector);
    } catch (Throwable ex) {
        throw new IllegalStateException("Unable to initialize MyBroadcaster", ex);
    }

}

我注意到的消息是正确到达JMS主题,但我收到以下异常:

SEVERE: A message body writer for Java class A, and Java type class A, and MIME       
   media type text/html was not found

   SEVERE: The registered message body writers compatible with the MIME media type are:

   */* ->
   com.sun.jersey.core.impl.provider.entity.FormProvider
   com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider
   com.sun.jersey.core.impl.provider.entity.StringProvider
   com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
   com.sun.jersey.core.impl.provider.entity.FileProvider
   com.sun.jersey.core.impl.provider.entity.InputStreamProvider
   com.sun.jersey.core.impl.provider.entity.DataSourceProvider
   com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
   com.sun.jersey.core.impl.provider.entity.ReaderProvider
   com.sun.jersey.core.impl.provider.entity.DocumentProvider
   com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
   com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
   com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
   com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
   com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
   com.sun.jersey.json.impl.provider.entity.JSONWithPaddingProvider
   com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
   com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
   com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
   com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
   com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
   com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
   com.sun.jersey.moxy.MoxyMessageBodyWorker
   com.sun.jersey.moxy.MoxyListMessageBodyWorker

我使用Netbeans 7.0.1,glassfish 3.1.1,气氛0.8.1,球衣1.11.我搜索了一个尝试任何可能的解决方案,但没有任何帮助.


以上所述就是小编给大家介绍的《没有找到Java类…和MIME媒体类型text / html的消息体编写器》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Programming Python

Programming Python

Mark Lutz / O'Reilly Media / 2006-8-30 / USD 59.99

Already the industry standard for Python users, "Programming Python" from O'Reilly just got even better. This third edition has been updated to reflect current best practices and the abundance of chan......一起来看看 《Programming Python》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具