NoSuchMethodError: Creating rest service

2019-09-06 03:19发布

问题:

I have written a JAX-RS service with following auto created interface from the wadl configuration. But I am landing into following issue. What can be the cause of this error? The service is running for single Play object, the Path params but not for ArrayOfPlay. I am able to send an ArrayOfPlay from the server to client but facing this trouble while sending from client to server.

 @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 version: 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;
    }
    
    }
    

Update: If I send a List instead of ArrayOfPlay I am able to make it work. How to represent as List in wadl? The current representation is:

<representation mediaType="application/xml" element="ns:ArrayOfPlay"/>
标签: rest cxf