找不到适用于媒体类型的JAXBContextFinder:application / json [英] Could not find JAXBContextFinder for media type: application/json

查看:143
本文介绍了找不到适用于媒体类型的JAXBContextFinder:application / json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有开发resteay + ejb + json的问题。使用Jboss-5.1.0.GA。我从resteasy-jaxrs得到例子,适应我的情况。
添加jars(这让我jboss,在其他情况下抓到异常 - 找不到类)到\jboss-5.1.0.GA\server\default\lib\

I have a problem with development resteay+ejb+json. Using Jboss-5.1.0.GA. I get example from resteasy-jaxrs and adapted to use for my case. Added jars(this ask me jboss. in other case catch exception - class not found) into \jboss-5.1.0.GA\server\default\lib\

resteasy-jaxb-provider-1.2.1.GA
jaxrs-api-2.0.1.GA
resteasy-jaxrs-2.0.1.GA

resteasy-jaxb-provider-1.2.1.GA jaxrs-api-2.0.1.GA resteasy-jaxrs-2.0.1.GA

获取异常

    09:43:15,502 ERROR [SynchronousDispatcher:error] Failed executing GET /basic
    org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: Could not find JAXBContextFinder for media type: application/json    
   at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.findJAXBContext(AbstractJAXBProvider.java:50)
    at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:127)
    at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:103)







<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>2.0.0.GA</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxb-provider</artifactId>
    <version>1.1.GA</version>
</dependency>







@Stateless
public class SimpleResourceBean implements SimpleResource {

    @Override
    public Book getBasic() {
        System.out.println("getBasic()");
        return new Book("AAA", "CCC", "SSSS");
    }  
}







@Path("/")
public interface SimpleResource {

    @GET
    @Path("basic")
   // @Produces("text/plain")
    @Produces("application/json")
    Book getBasic();

}







@BadgerFish
@XmlRootElement(name = "book")
public class Book
{   
   private String author;
   private String ISBN;
   private String title;

   public Book()
   {
   }

   public Book(String author, String ISBN, String title)
   {
      this.author = author;
      this.ISBN = ISBN;
      this.title = title;
   }

   @XmlElement
   public String getAuthor()
   {
      return author;
   }

   public void setAuthor(String author)
   {
      this.author = author;
   }

   @XmlElement
   public String getISBN()
   {
      return ISBN;
   }

   public void setISBN(String ISBN)
   {
      this.ISBN = ISBN;
   }

   @XmlAttribute
   public String getTitle()
   {
      return title;
   }

   public void setTitle(String title)
   {
      this.title = title;
   }
}






请,任何建议。
最好的问候
Artem


Please, any suggestion. Best regards Artem

推荐答案

RestEasy不再包含JAR中的JSON支持。
http:/ /docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html_single/index.html#JAXB_+_JSON_provider

RestEasy no longer includes JSON support in the JARs. http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html_single/index.html#JAXB_+_JSON_provider

您需要从 http://jettison.codehaus.org/ 获取一个JAX-B JSON库

You need to go get a JAX-B JSON library from http://jettison.codehaus.org/

这篇关于找不到适用于媒体类型的JAXBContextFinder:application / json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆