2015-02-01 8 views
7

मैं अगर कोई त्रुटि हुई एक गैर 200 प्रतिक्रिया सक्षम करने के लिए जर्सी डॉक्स का पालन करने के लिए कोशिश कर रहा हूँ नहीं मिला (https://jersey.java.net/documentation/latest/representations.html#d0e3586)जर्सी MessageBodyWriter मीडिया प्रकार = पाठ/सादे

मेरे कोड लगता है:

@POST 
@Produces(MediaType.TEXT_PLAIN) 
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) 
public ResponseBuilder getData(@FormParam("one") String one,@FormParam("two") String two,@FormParam("three") String three) { 
    if(one.isEmpty() || two.isEmpty() || three.isEmpty()) { 
     logger.error("Missing params for getData"); 
     throw new WebApplicationException(501); 
    } 
    return Response.ok(); 
} 
} 

[2015-02-01T16: 13: ०२.१५७ + 0000] [glassfish 4.1] [गंभीर] [] [org.glassfish.jersey.message.internal.WriterInterceptorExecutor

यह दुर्भाग्य निम्न त्रुटि पैदावार ] [tid: _ThreadID = 27 _ThreadName = http-listener-1 (2)] [timeMillis: 1422807182157] [levelValue: 1000] [[ संदेशबॉडीवाइटर मीडिया प्रकार = टेक्स्ट/सादा, प्रकार = वर्ग org.glassfish.jersey.message.internal.OutboundJaxrsResponse $ बिल्डर के लिए नहीं मिला , जेनेरिक टाइप = क्लास javax.ws.rs.core.Response $ ResponseBuilder।]]

उत्तर

6

समस्या आपकी विधि का रिटर्न प्रकार है। यह ResponseBuilder के बजाय Response होना चाहिए।

निम्नलिखित के लिए अपने कोड को बदलें और यह काम करना चाहिए:

@POST 
@Produces(MediaType.TEXT_PLAIN) 
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) 
public Response getData(@FormParam("one") String one,@FormParam("two") String two,@FormParam("three") String three) { 
    if(one.isEmpty() || two.isEmpty() || three.isEmpty()) { 
     logger.error("Missing params for getData"); 
     throw new WebApplicationException(501); 
    } 
    return Response.ok(); 
} 
+0

ओह मैं अभी इतना मूर्ख है! –

+0

यदि यह मदद नहीं करता है। मैं प्रतिक्रिया वापस करता हूँ। –

संबंधित मुद्दे