NoSuchMethodError:创建休息服务

时间:2015-09-30 10:02:34

标签: rest cxf

我已经编写了一个JAX-RS服务,其中包含来自wadl配置的以下自动创建的接口。但我正在进入以下问题。导致此错误的原因是什么?该服务正在运行单个Play对象,Path params但不适用于ArrayOfPlay。我可以从服务器向客户端发送一个ArrayOfPlay,但是在从客户端发送到服务器时遇到了这个问题。

 @Path("/play")
 public interface PlayService {


@POST
@Consumes({"application/xml", "application/json" })
@Produces({"application/xml", "application/json" })
@Path("/post")
Response postUpdate(ArrayOfPlay arrayofplay);

 }
java.lang.NoSuchMethodError: javax.ws.rs.InternalServerErrorException.validate(Ljavax/ws/rs/core/Response;Ljavax/ws/rs/core/Response$Status;)Ljavax/ws/rs/core/Response;
    at javax.ws.rs.InternalServerErrorException.<init>(InternalServerErrorException.java:126)
    at org.apache.cxf.jaxrs.utils.SpecExceptions.toInternalServerErrorException(SpecExceptions.java:79)
    at org.apache.cxf.jaxrs.utils.ExceptionUtils.toInternalServerErrorException(ExceptionUtils.java:106)
    at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.convertExceptionToResponseIfPossible(JAXRSInInterceptor.java:226)
    at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:215)
    at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:77)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
  • CXF版本:3.1.0

    ArrayOfPlay

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
    "play"
    })
    @XmlRootElement(name = "ArrayOfPlay")
     public class ArrayOfPlay
    implements Serializable
     {
    
     private final static long serialVersionUID = 1L;
       @XmlElement(name = "Play", required = true)
     protected List<Play> play;
    
     public List<Play> getPlay() {
    if (play == null) {
        play = new ArrayList<Play>();
    }
    return this.play;
    }
    
    }
    

更新:如果我发送一个List而不是ArrayOfPlay,我可以使它工作。如何在wadl中表示为List?目前的代表是:

<representation mediaType="application/xml" element="ns:ArrayOfPlay"/>

0 个答案:

没有答案