我需要包括泽西罐子在我Glassfish4.0服务器上的耳朵? [英] Do I need to include the Jersey Jars in my EAR on Glassfish4.0 server?

查看:157
本文介绍了我需要包括泽西罐子在我Glassfish4.0服务器上的耳朵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Firefox的海报,以测试在Glassfish 4.0运行新泽西RESTful Web服务。我得到一个HTTP服务器返回的海报输出500错误,当我返回一个Java类作为XML。当我返回一个字符串作为XML我没有得到一个错误。这使我想知道如果我需要在我的耳朵上Glassfish的任何JAX-RS瓶子或罐子新泽西州的。我在想,这些被列入Glassfish的模块,所以我不包括他们在我的WEB-INF lib目录下。

I am trying to use Firefox poster to test a Jersey restful webservice running on Glassfish 4.0. I am getting a HTTP Server 500 error returned to the Poster output when I return a java class as xml. I do not get an error when I return a String as xml. This makes me wonder if I need to include any of the JAX-RS jars or Jersey jars in my ear on Glassfish. I was thinking these were included in the Glassfish modules so I am not including them in my WEB-INF lib.

下面是一个什么样的作品为例,返回XML到Firefox海报:

Here is an example of what works, returns xml to firefox poster:

 @GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, "application/x-javascript", MediaType.APPLICATION_OCTET_STREAM } )
@Path( "/getTest/" )
public String getXml()
{
    return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";

}

下面是什么引发内部服务器错误500的示例:

Here is an example of what throws the Internal server error 500:

 @GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path( "/getTodo/" )
public Todo getXML() {
  Todo todo = new Todo();
  todo.setSummary("This is my first todo");
  todo.setDescription("This is my first todo");
  return todo;
}

 @XmlRootElement
 // JAX-RS supports an automatic mapping from JAXB annotated class to XML and JSON    
 // Isn't that cool?
 public class Todo {
   private String summary;
   private String description;
   public String getSummary() {
     return summary;
   }
   public void setSummary(String summary) {
     this.summary = summary;
   }
   public String getDescription() {
     return description;
    }
   public void setDescription(String description) {
     this.description = description;
   }
}

仅供参考 - 我松散继博客在这里 - restBlog

推荐答案

您绝对不需要包括任何在你的战争或耳文件的标准球衣文件,为他们在运行时访问。我当然有完全相同的那种东西你使用maven或机NetBeans 7.3.1项目做做工精细,无论是。

You definitely don't need to include any of the standard jersey files in your war or ear file for them to be accessible at runtime. I've certainly had exactly the kind of thing you're doing working fine, either using maven or native netbeans 7.3.1 projects.

我建议你看一下在GlassFish server.log文件,看precisely你越来越详细的错误。如果你缺少需要的jar文件,这应该告诉你。

I suggest you look at the glassfish server.log file to see precisely what the detailed error you are getting is. If you are missing needed jars, that should tell you.

这篇关于我需要包括泽西罐子在我Glassfish4.0服务器上的耳朵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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