【发布时间】:2013-11-20 01:31:55
【问题描述】:
我正在使用 JAX-RS 创建简单的 restful json,我的第一个方法工作正常,但是当我添加第二个来获取所有 vendorNOS"ID" 方法时,当我在浏览器中查看时出现此异常,我还调试了 Restful 服务和它工作正常它凝胶所有供应商NOS“ID”
my output from vendorFacadeBean is {1,2,3,4,5,6,11,13}
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=Application/json, type=class java.util.Vector, genericType=java.util.List<java.lang.Integer>.
root cause
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=Application/json, type=class java.util.Vector, genericType=java.util.List<java.lang.Integer>.
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.
GlassFish Server Open Source Edition 4.0
java源码
package resources;
import case2dtos.VendorEJBDTO;
import case2ejbs.VendorFacadeBean;
import java.util.List;
import javax.ejb.EJB;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.PathParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.enterprise.context.RequestScoped;
/**
* REST Web Service
*
* @author abdallaelnajjar
*/
@Path("vendors")
@RequestScoped
public class VendorsResource {
@EJB
private VendorFacadeBean vendorFacadeBean;
@Context
private UriInfo context;
/**
* Creates a new instance of VendorsResource
*/
public VendorsResource() {
}
/**
* Retrieves representation of an instance of resources.VendorsResource
* @return an instance of java.lang.String
*/
@GET
@Path("getAVendor/{vendorno}")
@Produces("Application/json")
public VendorEJBDTO getAVendor(@PathParam("vendorno")int vendorno)
{
return vendorFacadeBean.getVendorInfo(vendorno);
}
/**
* Retrieves representation of an instance of resources.VendorsResource
* @return an instance of java.lang.String
*/
@GET
@Path("getVendornos")
@Produces("Application/json")
public List<Integer> getVendornos()
{
List<Integer> vendornosList = null;
try
{
vendornosList = vendorFacadeBean.getVendorsnos();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
return vendornosList;
}
}
【问题讨论】:
标签: java json web-services glassfish