cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: JAX-RS POST error
Date Thu, 28 Jun 2012 11:54:38 GMT
It is all to do with either a malformed media type or wrong Accept type.
Can you capture what is on the wire ?
For example, add LoggingInInterceptor on the server side ?

Sergey

On 28/06/12 12:48, ramesh wrote:
> On 06/28/2012 06:40 AM, Sergey Beryozkin wrote:
>> What is the error you are seeing ? Do you use Jackson or the default
>> provider ?
>>
>> Sergey
>>
>> On 28/06/12 12:22, ramesh wrote:
>>> I am unable to pass JSON data as POST.
>>> { "Member":{"id":"3" , "city":"Tokyo", "country":"Japan" }}
>>> Is this the right format.
>>>
>>>
>>> this is my interface:
>>>
>>> @Path("/for")
>>> public interface ReqService {
>>>
>>> /**
>>> * Adds an invite requested by the guest.
>>> */
>>> @POST
>>> @Path("/invite")
>>> @Consumes("application/json")
>>> public void addMember(Member mem);
>>>
>>> }
>>>
>>> and this is my implementation:
>>>
>>> @Override
>>> public void addMember(Member mem){
>>> String rkey =mem.getId();
>>> String col1 = mem.getCity();
>>> String col2 = mem.getCountry();
>>> myDAO.insertMulti(rkey, col1, col2);
>>> }
>>>
>>> @XmlRootElement(name = "Member")
>>> @XmlType( propOrder = {"id", "city", "country" })
>>> public class Member {
>>> private String id;
>>> private String city;
>>> private String country;
>>>
>>> getters & setters ..
>>>
>>> regards,
>>> Ramesh
>>
>>
> Hi Sergey,
>
> I am using a webclient to pass this JSON.
> This is the error I get after I changed Consume to
> application/x-www-form-urlencoded.
>
> org.apache.cxf.interceptor.Fault
> at
> org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:110)
>
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:323)
>
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123)
>
> at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)
>
> at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)
>
> at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)
>
> at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126)
>
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
>
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107)
>
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
>
>
> If I use content type as JSON, I get status 415 and server throws this
> error
>
> javax.ws.rs.WebApplicationException
> at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:413)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:211)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:88)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:713)[63:org.apache.geronimo.specs.geronimo-servlet_2.5_spec:1.1.2]
>
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)[137:org.apache.cxf.bundle:2.5.0]
>
> at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)[73:org.eclipse.jetty.servlet:7.5.4.v20111024]
>
> at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:480)[73:org.eclipse.jetty.servlet:7.5.4.v20111024]
>
> at
> org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[83:org.ops4j.pax.web.pax-web-jetty:1.0.9]
>
>
> regards,
> Ramesh
>
>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message