Hi Andy
I'm nearly sure that the test will start working if you add the setters as
well...And may be remove @XmlElement method annotations...Can you try it and
let me know if it works ?
As far as the CGLIB-related test is concerned : I've updated the
2.2.4-SNAPSHOT client code recently to report a message and not to lose the
exception in such cases as well. Are you sure you have a cglib-nodep
dependency on the classpath ?
cheers, Sergey
amichalec wrote:
>
> Hi Sergey
>
>
> Sergey Beryozkin wrote:
>>
>> So as far as the NPE is concerned, it's coming from the JAXB layer, which
>> is then rethrown by JAXBElementProvider, right ?
>>
>> or is NPE originating from JAXBElementProvider.unmarshalFromReader() ?
>>
>
> It comes from JAXB layer, that's why I feel reluctant to dig deeper ;)
>
>
> Sergey Beryozkin wrote:
>>
>> This function is called if an XMLStreamReader has been found on a
>> message...
>> More information is needed, perhaps you can post a sample
>> JaxbEnrichedObject class ? Or some test case ?
>>
>
> Find attached maven project uploaded with this email. In this simplified
> case I do not hit NPE in JAXB but silently WebClient returns unmarshalled
> object that is empty inside (nulls instead of fulfilled fields).
>
>
> Find code snippets below:
>
> -------------------------------
> public class JaxrsService {
> @GET
> @Path("/foo")
> @Produces( "text/xml" )
> public Foo fooXml() {
> return new Foo("barval", "bazval");
> }
>
> @GET
> @Path("/foo")
> @Produces( "text/plain" )
> public String fooString() {
> return new Foo("barval", "bazval").toString();
> }
> }
>
> -------------------------------
> @XmlRootElement
> public class Foo {
> private String bar;
> private String baz;
> ...
>
> @XmlElement
> public String getBar() {
> return bar;
> }
>
> @XmlElement
> public String getBaz() {
> return baz;
> }
> ...
> }
>
> -------------------------------
> public class JaxrsServiceTest {
>
> private static Server server = null;
>
> @BeforeClass
> public static void beforeClass() throws Exception {
> server = new Server(6080);
> Context root = new Context(server, "/");
> ServletHolder servlet = new ServletHolder(
> new CXFNonSpringJaxrsServlet());
> servlet.setInitParameter("jaxrs.serviceClasses",
> "net.amichalec.wctest.JaxrsService");
> root.addServlet(servlet, "/");
> server.start();
> }
>
> @AfterClass
> public static void afterClass() throws Exception {
> server.stop();
> }
>
> @Test
> // it proves webclient and server work fine
> public void testNoJaxb() {
> WebClient wc = WebClient.create("http://localhost:6080");
> wc.path("/foo").accept("text/plain");
> String foo = wc.get(String.class);
> TestCase.assertEquals(new JaxrsService().fooString(), foo);
> }
>
> @Test
> // this time there is not NPE in unmarshalling but returned object
> // is empty (contain nulls)
> public void testJaxbFailing() {
> WebClient wc = WebClient.create("http://localhost:6080");
> wc.path("/foo").accept("text/xml");
> Foo foo = wc.get(Foo.class);
> TestCase.assertEquals(new JaxrsService().fooXml(), foo);
> }
>
> @Test
> // even though fromClient() offers cls parameter as
> // "if not interface then a CGLIB proxy will be created"
> // WAE is thrown (swallowing real cause "class is not interface")
> public void testProxyFailing() {
> WebClient wc = WebClient.create("http://localhost:6080");
> JaxrsService proxy = JAXRSClientFactory.fromClient(wc,
> JaxrsService.class);
> JaxrsService local = new JaxrsService();
> TestCase.assertEquals(local.fooXml(), proxy.fooXml());
> }
> }
>
> http://www.nabble.com/file/p25343761/webclient-test.zip
> webclient-test.zip
>
--
View this message in context:
http://www.nabble.com/WebClient-fails-to-unmarshall-tp25337879p25344274.html
Sent from the cxf-user mailing list archive at Nabble.com.