You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ramesh <my...@gmail.com> on 2012/06/28 13:22:44 UTC

JAX-RS POST error

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

Re: JAX-RS POST error

Posted by ramesh <my...@gmail.com>.
On 06/28/2012 09:28 AM, Sergey Beryozkin wrote:
> TCP traces utilities to capture the payload

Thanks Sergey, I will try that and I will upgrade CXF to 2.6.1

regards,

Ramesh

Re: JAX-RS POST error

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 28/06/12 14:23, ramesh wrote:
> On 06/28/2012 06:54 AM, Sergey Beryozkin wrote:
>> 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
>>>
>>>
>>>
>>>
>>
>>
> I am trying to add LoggingInInterceptor to my cxf osgi bundle.
>
> But Karaf headers show missing dependency and I don't see version 2.6.3
> in Maven.
>
> org.apache.cxf.interceptor;*version="[2.6,3)*"
>

The above trace suggests you are working with CXF 2.5.0 so I'm not sure 
where Karaf picks up a 2.6 bundle from. It's a version range, with an 
exclusive value on the right,

Perhaps you can use one of the TCP traces utilities to capture the payload ?

Sergey

> This is how I am trying to invoke in my blueprint
>
>
> <bean id="logInbound"
> class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
> <bean id="logOutbound"
> class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
>
> <jaxrs:server>
> <jaxrs:inInterceptors>
> <ref bean="logInbound"/>
> </jaxrs:inInterceptors>
> <jaxrs:outInterceptors>
> <ref bean="logOutbound"/>
> </jaxrs:outInterceptors>
> </jaxrs:server>
>
> Is this wrong ?
>
> regards,
> Ramesh
>
>


Re: JAX-RS POST error

Posted by ramesh <my...@gmail.com>.
On 06/28/2012 06:54 AM, Sergey Beryozkin wrote:
> 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
>>
>>
>>
>>
>
>
I am trying to add LoggingInInterceptor to my cxf osgi bundle.

But Karaf headers show missing dependency and I don't see version 2.6.3 
in Maven.

org.apache.cxf.interceptor;*version="[2.6,3)*"

This is how I am trying to invoke in my blueprint


<bean id="logInbound" 
class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="logOutbound" 
class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

<jaxrs:server>
  <jaxrs:inInterceptors>
      <ref bean="logInbound"/>
  </jaxrs:inInterceptors>
  <jaxrs:outInterceptors>
     <ref bean="logOutbound"/>
  </jaxrs:outInterceptors>
</jaxrs:server>

Is this wrong ?

regards,
Ramesh


Re: JAX-RS POST error

Posted by Sergey Beryozkin <sb...@gmail.com>.
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

Re: JAX-RS POST error

Posted by ramesh <my...@gmail.com>.
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





Re: JAX-RS POST error

Posted by Sergey Beryozkin <sb...@gmail.com>.
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


-- 
Sergey Beryozkin

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

Blog: http://sberyozkin.blogspot.com