Hi,

thanks for your feedback.
The HTTP Accept does contain application/json.
I wrote a small client with Apache Http client and set the Accept header
explicitly.
Also, the server log shows this.

Can you please let me one thing before I start debugging:
In how far is JAXB config needed in order to use JSON?

kind regards

Koen


2012/9/12 Sergey Beryozkin <[email protected]>

> Hi
>
> On 12/09/12 19:16, Koen Van Leuvenhaege wrote:
>
>> Hi,
>>
>> I'm trying to make a simple example work JAXRS example work, as described
>> below, but I do it using CXF-DOSGI.
>> (on Equinox, using declarative services)
>>
>> However, no matter how I configure my service, I always get a message:
>> 12-sep-2012 15:27:42 org.apache.cxf.jaxrs.**interceptor.**JAXRSOutInterceptor
>> writeResponseErrorMessage
>> WARNING: No message body writer has been found for response class
>> ElectriciteitsMeterStand.
>>
>> (class ElectriciteitsMeterStand is a simple POJO that is returned by one
>> of my methods, see code below)
>>
>> There must be something I'm overlooking, could you give any advice to
>> help me solve this problem?
>>
>> Code:
>> Service declaration in dOSGI:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <scr:component 
>> xmlns:scr="http://www.osgi.**org/xmlns/scr/v1.1.0<http://www.osgi.org/xmlns/scr/v1.1.0>"
>> immediate="false" name="EenvoudigeMeterOpname">
>>     <implementation class="projectone.**MeterOpnameImpl" />
>>
>>    <property name="service.exported.**interfaces" value="*" />
>>    <!-- property name="service.exported.**configs" value="
>> org.apache.cxf.ws" / -->
>>    <!-- property name="org.apache.cxf.ws.**address" value="
>> http://localhost:9090/**ws/meteropname<http://localhost:9090/ws/meteropname>"
>> / -->
>>    <property name="service.exported.**configs" value="org.apache.cxf.rs"
>> />
>>    <property name="org.apache.cxf.rs.**provider.expected" value="true" />
>>    <property name="org.apache.cxf.rs.**provider"
>> value="org.apache.cxf.jaxrs.**provider.JSONProvider" />
>>    <!-- property name="service.exported.**intents" value="HTTP" / -->
>>    <!-- property name="org.apache.cxf.rs.**databinding" value="jaxb" /
>> -->
>>    <service>
>>        <provide interface="projectone.**MeterOpname"/>
>>    </service>
>>
>> </scr:component>
>>
>>
> I've seen a few reports the default JSONProvider (and only JSONProvider)
> can not be used in some cases though I recall Angelo Zerr shown the
> configuration on this list on how JSONProvider can be set up and customized
> and it all worked, but I think it was done in Blueprint or Spring.
>
> The provider does not even have to be explicitly listed, something in
> (CXF) JSONUtils breaks...
>
> Can you also check HTTP Accept does contain application/json ?
> If not then I'd appreciate if you could debug it, I can help with setting
> it all up if you get a chance...
>
> Cheers, Sergey
>
>
>  Service interface:
>> package projectone;
>>
>> import javax.ws.rs.GET;
>> import javax.ws.rs.Path;
>> import javax.ws.rs.Produces;
>> import javax.xml.bind.annotation.**XmlRootElement;
>>
>> @Path("/rs")
>> @XmlRootElement
>> public interface MeterOpname {
>>
>>      /**
>>       * Returns the gas meter stand
>>       *
>>       * @return the gas meter stand
>>       */
>>         @GET
>>         @Path("getgas")
>>         @Produces({"application/json", "text/xml"})
>>      public String getGas();
>>
>>      /**
>>       * Returns the water meter stand
>>       *
>>       * @return the water meter stand
>>       */
>>         @GET
>>         @Path("getwater")
>>         @Produces({"application/json", "text/xml"})
>>      public String getWater();
>>
>>      /**
>>       * Returns the electriciteit meter stand
>>       *
>>       * @return the electriciteit meter stand
>>       */
>>         @GET
>>         @Path("getelectriciteit")
>>         @Produces({"application/json", "text/xml"})
>>      public ElectriciteitsMeterStand getElectriciteit();
>>
>> }
>>
>> Service Implementation:
>> package projectone;
>>
>> import javax.ws.rs.GET;
>> import javax.ws.rs.Path;
>> import javax.ws.rs.Produces;
>> import javax.xml.bind.annotation.**XmlRootElement;
>>
>> public class MeterOpnameImpl implements MeterOpname {
>>
>>         public String getGas() {
>>                 return toHtml(currentMethodName(), 10L);
>>         }
>>
>>         public String getWater() {
>>                 return toHtml(currentMethodName(), 100L);
>>         }
>>
>>         public ElectriciteitsMeterStand getElectriciteit() {
>>                 ElectriciteitsMeterStand result = new
>> ElectriciteitsMeterStand();
>>                 result.setDalVerbruik(50L);
>>                 result.setPiekVerbruik(150L);
>>                 return result;
>>
>>         }
>>
>>         private String toHtml(String title, Long value) {
>>                 return "<html><header></header><body>**<h1>" + title
>> +"</h1><p>" + value +"</p></body></html>";
>>         }
>>
>>         private String currentMethodName() {
>>                 StackTraceElement[] stacktrace = Thread.currentThread().*
>> *getStackTrace();
>>             StackTraceElement e = stacktrace[2];//coz 0th will be
>> getStackTrace so 1st
>>             return e.getMethodName();
>>         }
>>
>> }
>>
>> Return POJO:
>> package projectone;
>>
>> import javax.ws.rs.Produces;
>> import javax.xml.bind.annotation.**XmlRootElement;
>>
>> @Produces({"application/json", "text/xml"})
>> @XmlRootElement
>> public class ElectriciteitsMeterStand {
>>
>>         public ElectriciteitsMeterStand() {
>>
>>         }
>>
>>         private Long piekVerbruik;
>>         private Long dalVerbruik;
>>
>>         public Long getPiekVerbruik() {
>>                 return piekVerbruik;
>>         }
>>         public void setPiekVerbruik(Long piekVerbruik) {
>>                 this.piekVerbruik = piekVerbruik;
>>         }
>>         public Long getDalVerbruik() {
>>                 return dalVerbruik;
>>         }
>>         public void setDalVerbruik(Long dalVerbruik) {
>>                 this.dalVerbruik = dalVerbruik;
>>         }
>>
>>
>> }
>>
>>
>> Thanks in advance!
>>
>> kind regards
>>
>> Koen Van Leuvenhaege
>>
>>
>
>

Reply via email to