You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by christoe <ch...@enqvi.st> on 2009/06/07 13:27:57 UTC

Message body reader for JAXB

Hi,

I'm trying to get my RESTful web service methods to work, but I keep getting
these errors:

Jun 7, 2009 1:07:27 PM org.apache.cxf.jaxrs.utils.JAXRSUtils
readFromMessageBody
WARNING: .No message body reader found for request class : User, ContentType
: application/xml.
Jun 7, 2009 1:07:27 PM
org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available

To put this more into context, code snippets can be found at:
http://pastebin.com/m63d132ee

The entity-bean User is automatically generated by JAXB, and therefore I
expected it to work out of the box with the CXF JAXBElementProvider. However
this does not seem to be the case. What is causing these problems? Are the
entity-beans missing some annotation so that the Message body reader does
not recognize it? Can the fact that the entity-beans/web service and the
software initializing the service have different context paths have anything
to do with it?

Thankful for any response,

/Christoffer
-- 
View this message in context: http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23910035.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Message body reader for JAXB

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

Did you have any progress on this issue ? If not then may be you can package a sample project which reproduces the issue and I'll 
proceed from there ?

cheers, Sergey


> Hi,
>
> this is the code which tries to preload ObjectFactory, the loader which loaded a type like User is asked to load an Object factory 
> :
>
> Class<?> type = ...
>
> type.getClassLoader().loadClass(PackageUtils.getPackageName(type) + ".ObjectFactory");
>
> for some reasons this factory can not be found...
>
> is there any chance for you to simplify the deployment of the endpoint, just for a test, and see if it makes any difference.
> May be I need to enhance this logic a bit and say delegate to ClassLoaderUtils as the last resort...
>
> thanks, Sergey
> ----- Original Message ----- 
>
> From: "christoe" <ch...@enqvi.st>
> To: <us...@cxf.apache.org>
> Sent: Monday, June 08, 2009 10:32 AM
> Subject: Re: Message body reader for JAXB
>
>
>>
>> Hi,
>>
>> Yes, in the same package I've got the ObjectFactory:
>> http://pastebin.com/m1b000355
>> I'd like to think that they are correctly generated by JAXB and the error
>> lies elsewhere.
>> How does the JAXBElementProvider resolve these classes? Could the fact that
>> the web service is started by reflection with another classpath than the
>> class starting the web service have anything to do with it? If so, how to
>> solve it?
>>
>> Cheers,
>> Christoffer
>>
>>
>> Sergey Beryozkin-2 wrote:
>>>
>>> Hi,
>>>
>>> JAXBElementProvider will deal with those classes which have XmlRootElement
>>> annotations. It also checks for ObjectFactory.
>>> Do you have repository.wsp1427297922.schemaTypes.ObjectFactory generated
>>> as well ?
>>>
>>> cheers, Sergey
>>>
>>>>
>>>> Hi,
>>>>
>>>> I'm trying to get my RESTful web service methods to work, but I keep
>>>> getting
>>>> these errors:
>>>>
>>>> Jun 7, 2009 1:07:27 PM org.apache.cxf.jaxrs.utils.JAXRSUtils
>>>> readFromMessageBody
>>>> WARNING: .No message body reader found for request class : User,
>>>> ContentType
>>>> : application/xml.
>>>> Jun 7, 2009 1:07:27 PM
>>>> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>>>> WARNING: WebApplicationException has been caught : no cause is available
>>>>
>>>> To put this more into context, code snippets can be found at:
>>>> http://pastebin.com/m63d132ee
>>>>
>>>> The entity-bean User is automatically generated by JAXB, and therefore I
>>>> expected it to work out of the box with the CXF JAXBElementProvider.
>>>> However
>>>> this does not seem to be the case. What is causing these problems? Are
>>>> the
>>>> entity-beans missing some annotation so that the Message body reader does
>>>> not recognize it? Can the fact that the entity-beans/web service and the
>>>> software initializing the service have different context paths have
>>>> anything
>>>> to do with it?
>>>>
>>>> Thankful for any response,
>>>>
>>>> /Christoffer
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23910035.html
>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> -- 
>> View this message in context: http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23920806.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
> 


Re: Message body reader for JAXB

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,

this is the code which tries to preload ObjectFactory, the loader which loaded a type like User is asked to load an Object factory :

Class<?> type = ...

type.getClassLoader().loadClass(PackageUtils.getPackageName(type) + ".ObjectFactory");

for some reasons this factory can not be found...

is there any chance for you to simplify the deployment of the endpoint, just for a test, and see if it makes any difference.
May be I need to enhance this logic a bit and say delegate to ClassLoaderUtils as the last resort...

thanks, Sergey
----- Original Message ----- 

From: "christoe" <ch...@enqvi.st>
To: <us...@cxf.apache.org>
Sent: Monday, June 08, 2009 10:32 AM
Subject: Re: Message body reader for JAXB


>
> Hi,
>
> Yes, in the same package I've got the ObjectFactory:
> http://pastebin.com/m1b000355
> I'd like to think that they are correctly generated by JAXB and the error
> lies elsewhere.
> How does the JAXBElementProvider resolve these classes? Could the fact that
> the web service is started by reflection with another classpath than the
> class starting the web service have anything to do with it? If so, how to
> solve it?
>
> Cheers,
> Christoffer
>
>
> Sergey Beryozkin-2 wrote:
>>
>> Hi,
>>
>> JAXBElementProvider will deal with those classes which have XmlRootElement
>> annotations. It also checks for ObjectFactory.
>> Do you have repository.wsp1427297922.schemaTypes.ObjectFactory generated
>> as well ?
>>
>> cheers, Sergey
>>
>>>
>>> Hi,
>>>
>>> I'm trying to get my RESTful web service methods to work, but I keep
>>> getting
>>> these errors:
>>>
>>> Jun 7, 2009 1:07:27 PM org.apache.cxf.jaxrs.utils.JAXRSUtils
>>> readFromMessageBody
>>> WARNING: .No message body reader found for request class : User,
>>> ContentType
>>> : application/xml.
>>> Jun 7, 2009 1:07:27 PM
>>> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>>> WARNING: WebApplicationException has been caught : no cause is available
>>>
>>> To put this more into context, code snippets can be found at:
>>> http://pastebin.com/m63d132ee
>>>
>>> The entity-bean User is automatically generated by JAXB, and therefore I
>>> expected it to work out of the box with the CXF JAXBElementProvider.
>>> However
>>> this does not seem to be the case. What is causing these problems? Are
>>> the
>>> entity-beans missing some annotation so that the Message body reader does
>>> not recognize it? Can the fact that the entity-beans/web service and the
>>> software initializing the service have different context paths have
>>> anything
>>> to do with it?
>>>
>>> Thankful for any response,
>>>
>>> /Christoffer
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23910035.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23920806.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 


Re: Message body reader for JAXB

Posted by christoe <ch...@enqvi.st>.
Hi,

Yes, in the same package I've got the ObjectFactory:
http://pastebin.com/m1b000355
I'd like to think that they are correctly generated by JAXB and the error
lies elsewhere. 
How does the JAXBElementProvider resolve these classes? Could the fact that
the web service is started by reflection with another classpath than the
class starting the web service have anything to do with it? If so, how to
solve it?

Cheers,
Christoffer


Sergey Beryozkin-2 wrote:
> 
> Hi,
> 
> JAXBElementProvider will deal with those classes which have XmlRootElement
> annotations. It also checks for ObjectFactory.
> Do you have repository.wsp1427297922.schemaTypes.ObjectFactory generated
> as well ?
> 
> cheers, Sergey
> 
>> 
>> Hi,
>> 
>> I'm trying to get my RESTful web service methods to work, but I keep
>> getting
>> these errors:
>> 
>> Jun 7, 2009 1:07:27 PM org.apache.cxf.jaxrs.utils.JAXRSUtils
>> readFromMessageBody
>> WARNING: .No message body reader found for request class : User,
>> ContentType
>> : application/xml.
>> Jun 7, 2009 1:07:27 PM
>> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>> WARNING: WebApplicationException has been caught : no cause is available
>> 
>> To put this more into context, code snippets can be found at:
>> http://pastebin.com/m63d132ee
>> 
>> The entity-bean User is automatically generated by JAXB, and therefore I
>> expected it to work out of the box with the CXF JAXBElementProvider.
>> However
>> this does not seem to be the case. What is causing these problems? Are
>> the
>> entity-beans missing some annotation so that the Message body reader does
>> not recognize it? Can the fact that the entity-beans/web service and the
>> software initializing the service have different context paths have
>> anything
>> to do with it?
>> 
>> Thankful for any response,
>> 
>> /Christoffer
>> -- 
>> View this message in context:
>> http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23910035.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>> 
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23920806.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Message body reader for JAXB

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi,

JAXBElementProvider will deal with those classes which have XmlRootElement annotations. It also checks for ObjectFactory.
Do you have repository.wsp1427297922.schemaTypes.ObjectFactory generated as well ?

cheers, Sergey

> 
> Hi,
> 
> I'm trying to get my RESTful web service methods to work, but I keep getting
> these errors:
> 
> Jun 7, 2009 1:07:27 PM org.apache.cxf.jaxrs.utils.JAXRSUtils
> readFromMessageBody
> WARNING: .No message body reader found for request class : User, ContentType
> : application/xml.
> Jun 7, 2009 1:07:27 PM
> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
> WARNING: WebApplicationException has been caught : no cause is available
> 
> To put this more into context, code snippets can be found at:
> http://pastebin.com/m63d132ee
> 
> The entity-bean User is automatically generated by JAXB, and therefore I
> expected it to work out of the box with the CXF JAXBElementProvider. However
> this does not seem to be the case. What is causing these problems? Are the
> entity-beans missing some annotation so that the Message body reader does
> not recognize it? Can the fact that the entity-beans/web service and the
> software initializing the service have different context paths have anything
> to do with it?
> 
> Thankful for any response,
> 
> /Christoffer
> -- 
> View this message in context: http://www.nabble.com/Message-body-reader-for-JAXB-tp23910035p23910035.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
>