Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot consume content type-RestEasy

I develop RestEasy web service(maven/java/tomcat I use for develop the web service) then i got massage Cannot consume content type like this. Why I got like this error,

2015-10-19 17:55:02,823 [http-nio-8080-exec-10] WARN  org.jboss.resteasy.core.ExceptionHandler  - failed to execute
javax.ws.rs.NotSupportedException: Cannot consume content type
    at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:380)
    at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114)
    at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43)
    at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
    at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
    at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

My java class like this,

@POST
@Path("/createMime")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_FORM_URLENCODED })
public String createMime(CategoryType categoryType) throws MyRestException {

        logger.info("Processing /createMime");
        //same code here
        return userDAO.category(categoryType);
    }

How I solve that question? below image is my request sent thought Rest client

enter image description here

like image 606
Thilina Sampath Avatar asked Oct 20 '15 04:10

Thilina Sampath


1 Answers

I there add this for headers, success full sent massage.

Content-Type: application/xml
Accept: application/x-www-form-urlencoded

this is the I got response,

Status Code: 200 OK
Content-Length: 59
Content-Type: application/x-www-form-urlencoded
Date: Tue, 20 Oct 2015 05:39:46 GMT
Server: Apache-Coyote/1.1
like image 117
Thilina Sampath Avatar answered Sep 18 '22 23:09

Thilina Sampath