Hello Sergey, Thank you. I've added an issue for this: CXF-4380
Maybe the description there is better than in my last mail. Best regards, Marko Am 14.06.2012 17:04, schrieb Sergey Beryozkin: > Hi Marko > On 14/06/12 14:48, Voß, Marko wrote: >> Hello, >> >> I think, I know the problem. >> >> I have written an example like this: >> >> --- >> FooTO foo = new FooTO(); >> >> JAXBContext context = >> JAXBContext.newInstance(foo.getClass().getPackage().getName()); >> // this context looks like the context from AbstractJAXBProvider:438 (both >> support the same types) >> context.createMarshaller().marshal(foo, outputStream); >> InputStream in = /* make inputstream from outputstream */ >> >> context.createUnmarshaller().unmarshal(in) // works >> context.createUnmarshaller().unmarshal(new StreamSource(in), foo.getClass()) >> // fails because FooTO is not known to >> this context >> > JAXBElementProvider uses the StaxReader as the first argument. >> >> CXF is using the second unmarshalling behavior. >> >> Any ideas, how to get around this? >> > > Try setting an extraClass[] property, that should do it. I'll fix it in > meantime. > By the way: > http://cxf.apache.org/docs/jax-rs-advanced-xml.html#JAX-RSAdvancedXML-XMLProcessingInstructions > > Perhaps that can let you to avoid providing a custom provider > > Cheers, Sergey > >> >> >> Best regards, >> Marko >> >> -----Original Message----- >> From: Voß, Marko [mailto:[email protected]] >> Sent: Thursday, June 14, 2012 3:13 PM >> To: Sergey Beryozkin; [email protected] >> Subject: RE: JAXBElementProvider not able to deal with specific type of >> classes? >> >> Hello Sergey, >> >> I've updated from CXF 2.5.1 to 2.6.1. >> >> We are using our own JAXBElementProvider, which extends from >> JAXBElementProvider in order to add a xml-stylesheet to >> the top of the returned XML. >> >> I had to change the code from: >> >> MyJAXBElementProvider extends JAXBElementProvider >> >> To: >> >> MyJAXBElementProvider extends JAXBElementProvider<Object> >> >> Otherwise the code could not compile because of the overridden method >> setMarshallerProperties. >> >> Maybe it has something to do with this? I doubt that. >> >> I was performing a manual un-/marshalling of this kind of class and it >> worked. I have no idea what is wrong here. Both >> JAXBContext instances have the same output for toString(). >> >> >> Best regards, >> >> Marko Voß >> ePublishing& eScience >> Development& Applied Research >> Phone +49 7247 808-744 >> Fax +49 7247 808-133 >> [email protected] >> >> >> FIZ Karlsruhe - Leibniz Institute for Information Infrastructure >> Hermann-von-Helmholtz-Platz 1 >> 76344 Eggenstein-Leopoldshafen, Germany >> >> www.fiz-karlsruhe.de >> >> >> >> -----Original Message----- >> From: Sergey Beryozkin [mailto:[email protected]] >> Sent: Thursday, June 14, 2012 2:01 PM >> To: [email protected] >> Cc: Voß, Marko >> Subject: Re: JAXBElementProvider not able to deal with specific type of >> classes? >> >> Hi Marko >> On 14/06/12 12:29, Voß, Marko wrote: >>> Hello, >>> >>> (CXF v2.6.1) >>> >>> We have, say, a JAX-RS interface like this one: >>> >>> --- >>> @Path("/foo") >>> public interface Foo { >>> >>> @Path("/bar") >>> @POST >>> @Consumes(MediaType.TEXT_XML) >>> @Produces(MediaType.TEXT_XML) >>> JAXBElement<BarTypeTO> doSomething(FooTO); } >>> --- >>> >>> FooTO is a class of the following structure (generated by >>> JAXB-Maven-Plugin): >>> >>> --- >>> public class FooTO extends JAXBElement<ExampleTypeTO> { >>> >>> protected final static Qname NAME = new Qname("namespace", "foo"); >>> >>> public FooTO(ExampleTypeTO value) { >>> super(NAME, ((Class) ExampleTypeTO.class), null, value); >>> } >>> >>> public FooTO() { >>> super(NAME, ((Class) ExampleTypeTO.class), null, null); >>> } >>> } >>> --- >>> >>> ExampleTypeTO represents a schema complexType. Schema: >>> >>> --- >>> <xs:element name="foo" type="exampleType"/> >>> >>> <xs:complexType name"exampleType">...</xs:complexType> >>> --- >>> >>> Now, when performing a request to the endpoint from above, I get the >>> following exception: >>> >>> JAXBException: FooTO is not known to this context. >>> >>> I debugged JAXBElementProvider and the JAXBContext instance knows all >>> classes from the package of FooTO except FooTO >>> itself and of course the ObjectFactory, which may be correct but why is >>> JAXB not able to unmarshal FooTO? This was >>> working once. >>> >>> Is there something wrong at line 173-175 in JAXBElementProvider? >>> >> >> I do not actually remember changing anything that may've affected the >> processing of classes like FooTO which extend >> JAXBElement. >> When did it work last time ? May be it is to do with the JAXB impl versions ? >> >> Thanks, Sergey >> >>> >>> Best regards, >>> Marko >>> >>> >>> ------------------------------------------------------- >>> >>> Fachinformationszentrum Karlsruhe, Gesellschaft für >>> wissenschaftlich-technische Information mbH. >>> Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB >>> 101892. >>> Geschäftsführerin: Sabine Brünger-Weilandt. >>> Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner. >>> >>> >> >> >> ------------------------------------------------------- >> >> Fachinformationszentrum Karlsruhe, Gesellschaft für >> wissenschaftlich-technische Information mbH. >> Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB >> 101892. >> Geschäftsführerin: Sabine Brünger-Weilandt. >> Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner. >> >> >> >> >> ------------------------------------------------------- >> >> Fachinformationszentrum Karlsruhe, Gesellschaft für >> wissenschaftlich-technische Information mbH. >> Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB >> 101892. >> Geschäftsführerin: Sabine Brünger-Weilandt. >> Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner. >> >> > > -- Marko Voß ePublishing & eScience Development & Applied Research Phone +49 7247 808-744 Fax +49 7247 808-133 [email protected] FIZ Karlsruhe - Leibniz Institute for Information Infrastructure Hermann-von-Helmholtz-Platz 1 76344 Eggenstein-Leopoldshafen, Germany www.fiz-karlsruhe.de ------------------------------------------------------- Fachinformationszentrum Karlsruhe, Gesellschaft für wissenschaftlich-technische Information mbH. Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB 101892. Geschäftsführerin: Sabine Brünger-Weilandt. Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner.
