thanks, I'll try to checkout the nightly's to try it out

On Fri, May 11, 2012 at 11:09 PM, Sergey Beryozkin <[email protected]>wrote:

> As it happens the code I copied from the CXF JAXB DataBinding to do with
> managing schemas with the empty namespaces and then modified was broken, so
> I fixed that.
>
> The code in the CXF Data Bindings is much more involved but for now I'm
> assuming that we have simple cases like the typical root resource with
> manually created JAXB classes, no Objectfactory, etc...We can extend the
> relevant code if ever needed.
>
> I also fixed an issue with WADLGenerator not linking in case of
> XMLRootElement missing a name attribute
>
> Cheers, Sergey
>
>
> On 11/05/12 12:12, Sergey Beryozkin wrote:
>
>> I reproduced it.
>> Basically what happens is that the below TestCompositeObject gets
>> represented by two schemas in the grammar section:
>>
>> <xs:schema attributeFormDefault="**unqualified"
>> elementFormDefault="**unqualified">
>>
>> <xs:complexType name="testCompositeObject">
>> <xs:sequence>
>> <xs:element name="id" type="xs:int"/>
>> <xs:element minOccurs="0" name="name" type="xs:string"/> </xs:sequence>
>> </xs:complexType>
>>
>> </xs:schema>
>>
>> <xs:schema attributeFormDefault="**unqualified"
>> elementFormDefault="**unqualified"
>> targetNamespace="http://**example.com/test <http://example.com/test>">
>>
>> <xs:import/>
>>
>> <xs:element name="test" type="testCompositeObject"/>
>> </xs:schema>
>>
>>
>> Both scheme representations are accepted before the compilation but the
>> compiler is not 'willing' to resolve the references to types residing in
>> the schema without a target namespace.
>>
>> I've no idea at the moment how to deal with it.
>> Additionally adding @XmlType(name = "testType", namespace =
>> "http://example.com/test";) fixes the multi-schema generation, which I
>> guess is the case when JAXB classes have been generated from the
>> existing schemas, but I guess it should be somehow possible either
>> customize the schema generation in the WADLGenerator to get a single
>> schema produced or tweak the schema compiler to process the above two
>> schemas, something to figure out...
>>
>> Sergey
>>
>>
>>
>> On 10/05/12 23:34, Ted wrote:
>>
>>> I'd actually tried that when I added the namespace too, it didn't help
>>> so I
>>> didn't mention it before. I just tried it again with similar results, the
>>> parameter is still missing although the wadl is slightly different due to
>>> the name now :
>>>
>>> @XmlRootElement(name = "TestCompositeObject", namespace = "
>>> http://example.com/test";)
>>> public static class TestCompositeObject
>>> {
>>> public int id = 23;
>>> public String name = "asdf";
>>> }
>>>
>>> wadl produces :
>>>
>>> <resource path="/setTest3">
>>> <method name="PUT" id="setTest3">
>>> <request>
>>> <representation mediaType="application/xml"
>>> element="prefix1:**TestCompositeObject"/>
>>> </request>
>>> <response>
>>> <representation mediaType="application/xml"
>>> element="prefix1:**TestCompositeObject"/>
>>> </response>
>>> </method>
>>> </resource>
>>>
>>> The exception on wadl2java generation is still similar :
>>>
>>> [java] WADLToJava Error: java.lang.reflect.**
>>> UndeclaredThrowableException
>>> [java]
>>> [java] org.apache.cxf.tools.common.**ToolException:
>>> java.lang.reflect.**UndeclaredThrowableException
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.JAXRSContainer.execute(**
>>> JAXRSContainer.java:82)
>>>
>>> [java] at
>>> org.apache.cxf.tools.common.**toolspec.ToolRunner.runTool(**
>>> ToolRunner.java:103)
>>>
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**WADLToJava.run(WADLToJava.**java:65)
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**WADLToJava.run(WADLToJava.**java:57)
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**WADLToJava.main(WADLToJava.**java:99)
>>> [java] Caused by: java.lang.reflect.**UndeclaredThrowableException
>>> [java] at $Proxy9.bind(Unknown Source)
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.SourceGenerator.**createCodeModel(**
>>> SourceGenerator.java:1196)
>>>
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.SourceGenerator.**
>>> generateSchemaCodeAndInfo(**SourceGenerator.java:231)
>>>
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.SourceGenerator.**generateSource(**
>>> SourceGenerator.java:220)
>>>
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.JAXRSContainer.**
>>> processWadl(JAXRSContainer.**java:151)
>>>
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.JAXRSContainer.execute(**
>>> JAXRSContainer.java:65)
>>>
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.JAXRSContainer.execute(**
>>> JAXRSContainer.java:74)
>>>
>>> [java] ... 4 more
>>> [java] Caused by: java.lang.reflect.**InvocationTargetException
>>> [java] at sun.reflect.**NativeMethodAccessorImpl.**invoke0(Native
>>> Method)
>>> [java] at
>>> sun.reflect.**NativeMethodAccessorImpl.**invoke(**
>>> NativeMethodAccessorImpl.java:**39)
>>>
>>> [java] at
>>> sun.reflect.**DelegatingMethodAccessorImpl.**invoke(**
>>> DelegatingMethodAccessorImpl.**java:25)
>>>
>>> [java] at java.lang.reflect.Method.**invoke(Method.java:597)
>>> [java] at
>>> org.apache.cxf.common.util.**ReflectionInvokationHandler.**invoke(**
>>> ReflectionInvokationHandler.**java:52)
>>>
>>> [java] ... 11 more
>>> [java] Caused by: java.lang.reflect.**UndeclaredThrowableException
>>> [java] at $Proxy13.error(Unknown Source)
>>> [java] at
>>> com.sun.tools.xjc.api.impl.**s2j.SchemaCompilerImpl.error(**
>>> SchemaCompilerImpl.java:316)
>>>
>>> [java] at
>>> com.sun.tools.xjc.util.**ErrorReceiverFilter.error(**
>>> ErrorReceiverFilter.java:82)
>>>
>>> [java] at
>>> com.sun.xml.xsom.impl.parser.**ParserContext$2.error(**
>>> ParserContext.java:206)
>>>
>>> [java] at
>>> com.sun.xml.xsom.impl.parser.**ParserContext$1.reportError(**
>>> ParserContext.java:184)
>>>
>>> [java] at
>>> com.sun.xml.xsom.impl.parser.**NGCCRuntimeEx.reportError(**
>>> NGCCRuntimeEx.java:175)
>>>
>>> [java] at
>>> com.sun.xml.xsom.impl.parser.**DelayedRef.resolve(DelayedRef.**java:110)
>>> [java] at
>>> com.sun.xml.xsom.impl.parser.**DelayedRef.run(DelayedRef.**java:85)
>>> [java] at
>>> com.sun.xml.xsom.impl.parser.**ParserContext.getResult(**
>>> ParserContext.java:135)
>>>
>>> [java] at
>>> com.sun.xml.xsom.parser.**XSOMParser.getResult(**XSOMParser.java:211)
>>> [java] at
>>> com.sun.tools.xjc.ModelLoader.**createXSOM(ModelLoader.java:**532)
>>> [java] at
>>> com.sun.tools.xjc.api.impl.**s2j.SchemaCompilerImpl.bind(**
>>> SchemaCompilerImpl.java:268)
>>>
>>> [java] ... 16 more
>>> [java] Caused by: java.lang.reflect.**InvocationTargetException
>>> [java] at sun.reflect.**NativeMethodAccessorImpl.**invoke0(Native
>>> Method)
>>> [java] at
>>> sun.reflect.**NativeMethodAccessorImpl.**invoke(**
>>> NativeMethodAccessorImpl.java:**39)
>>>
>>> [java] at
>>> sun.reflect.**DelegatingMethodAccessorImpl.**invoke(**
>>> DelegatingMethodAccessorImpl.**java:25)
>>>
>>> [java] at java.lang.reflect.Method.**invoke(Method.java:597)
>>> [java] at
>>> org.apache.cxf.common.util.**ReflectionInvokationHandler.**invoke(**
>>> ReflectionInvokationHandler.**java:52)
>>>
>>> [java] ... 28 more
>>> [java] Caused by: java.lang.RuntimeException: Error compiling schema
>>> from WADL : undefined simple or complex type 'testCompositeObject'
>>> [java] at
>>> org.apache.cxf.tools.wadlto.**jaxrs.SourceGenerator$**
>>> InnerErrorListener.error(**SourceGenerator.java:1343)
>>>
>>> [java] ... 33 more
>>> [java] Caused by: org.xml.sax.SAXParseException: undefined simple or
>>> complex type 'testCompositeObject'
>>> [java] at
>>> com.sun.xml.xsom.impl.parser.**ParserContext$1.reportError(**
>>> ParserContext.java:180)
>>>
>>> [java] ... 23 more
>>>
>>>
>>> On Fri, May 11, 2012 at 7:38 AM, Sergey
>>> Beryozkin<[email protected]**>wrote:
>>>
>>>  Well, it is the second time I'm seeing XmlRootElement with a namespace
>>>> attribute but without a name attribute, and in both cases the same
>>>> issue of
>>>> the badly generated WADL has been discussed :-), so it is time to
>>>> support
>>>> this variation too.
>>>>
>>>> Yes, the JAXB Data Binding section does not show a namespace
>>>> attribute in
>>>> action, it is not that important for that section, besides using this
>>>> attribute is not the only way to provide a namespace for JAXB.
>>>>
>>>> I think an empty XMLRootElement works OK when ObjectFactory is also
>>>> available...
>>>> In meantime, add an explicit name attribute too
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>>
>>>> On 10/05/12 21:20, Ted wrote:
>>>>
>>>>  None of the examples I've seen have had to do that. Even the "basic"
>>>>> sample
>>>>> in cxf doesn't seem to do that. If I look at the sample
>>>>> Customer/Order/Product classes none of them have an explicit namespace
>>>>> declaration.
>>>>>
>>>>> I gave it a try anyways :
>>>>>
>>>>> @XmlRootElement(namespace = "http://example.com/test";)
>>>>> public static class TestCompositeObject
>>>>> {
>>>>> public int id = 23;
>>>>> public String name = "asdf";
>>>>> }
>>>>>
>>>>> I can see wadl has changed to have the namespace for the
>>>>> TestCompositeObject entry. The method itself though has not changed :
>>>>>
>>>>> <resource path="/setTest3">
>>>>> <method name="PUT" id="setTest3">
>>>>> <request>
>>>>> <representation mediaType="application/xml"/>
>>>>> </request>
>>>>> <response>
>>>>> <representation mediaType="application/xml"/>
>>>>> </response>
>>>>> </method>
>>>>> </resource>
>>>>>
>>>>> When I call wadl2java on it, I get an exception : (I'm using jdk
>>>>> 1.6.0_26-b03 on linux, and cxf 2.6.0)
>>>>>
>>>>> [java] WADLToJava Error: java.lang.reflect.**
>>>>> UndeclaredThrowableException
>>>>> [java]
>>>>> [java] org.apache.cxf.tools.common.****ToolException:
>>>>> java.lang.reflect.****UndeclaredThrowableException
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.JAXRSContainer.execute(****
>>>>> JAXRSContainer.java:82)
>>>>> [java] at
>>>>> org.apache.cxf.tools.common.****toolspec.ToolRunner.runTool(**
>>>>> ToolRunner.java:103)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****WADLToJava.run(WADLToJava.****java:65)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****WADLToJava.run(WADLToJava.****java:57)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****WADLToJava.main(WADLToJava.****
>>>>> java:99)
>>>>> [java] Caused by: java.lang.reflect.****UndeclaredThrowableException
>>>>> [java] at $Proxy9.bind(Unknown Source)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.SourceGenerator.****
>>>>> createCodeModel(**
>>>>>
>>>>> SourceGenerator.java:1196)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.SourceGenerator.**
>>>>> generateSchemaCodeAndInfo(****SourceGenerator.java:231)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.SourceGenerator.****
>>>>> generateSource(**
>>>>> SourceGenerator.java:220)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.JAXRSContainer.**
>>>>> processWadl(JAXRSContainer.****java:151)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.JAXRSContainer.execute(****
>>>>> JAXRSContainer.java:65)
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.JAXRSContainer.execute(****
>>>>> JAXRSContainer.java:74)
>>>>> [java] ... 4 more
>>>>> [java] Caused by: java.lang.reflect.****InvocationTargetException
>>>>> [java] at sun.reflect.****NativeMethodAccessorImpl.**
>>>>> invoke0(Native
>>>>> Method)
>>>>> [java] at
>>>>> sun.reflect.****NativeMethodAccessorImpl.****invoke(**
>>>>> NativeMethodAccessorImpl.java:****39)
>>>>> [java] at
>>>>> sun.reflect.****DelegatingMethodAccessorImpl.****invoke(**
>>>>> DelegatingMethodAccessorImpl.****java:25)
>>>>> [java] at java.lang.reflect.Method.****invoke(Method.java:597)
>>>>> [java] at
>>>>> org.apache.cxf.common.util.****ReflectionInvokationHandler.****
>>>>> invoke(**
>>>>> ReflectionInvokationHandler.****java:52)
>>>>> [java] ... 11 more
>>>>> [java] Caused by: java.lang.reflect.****UndeclaredThrowableException
>>>>> [java] at $Proxy13.error(Unknown Source)
>>>>> [java] at
>>>>> com.sun.tools.xjc.api.impl.****s2j.SchemaCompilerImpl.error(****
>>>>> SchemaCompilerImpl.java:316)
>>>>> [java] at
>>>>> com.sun.tools.xjc.util.****ErrorReceiverFilter.error(**
>>>>> ErrorReceiverFilter.java:82)
>>>>> [java] at
>>>>> com.sun.xml.xsom.impl.parser.****ParserContext$2.error(**
>>>>> ParserContext.java:206)
>>>>> [java] at
>>>>> com.sun.xml.xsom.impl.parser.****ParserContext$1.reportError(****
>>>>> ParserContext.java:184)
>>>>> [java] at
>>>>> com.sun.xml.xsom.impl.parser.****NGCCRuntimeEx.reportError(**
>>>>> NGCCRuntimeEx.java:175)
>>>>> [java] at
>>>>> com.sun.xml.xsom.impl.parser.****DelayedRef.resolve(**
>>>>> DelayedRef.**java:110)
>>>>>
>>>>> [java] at
>>>>> com.sun.xml.xsom.impl.parser.****DelayedRef.run(DelayedRef.****
>>>>> java:85)
>>>>> [java] at co
>>>>> [java]
>>>>> m.sun.xml.xsom.impl.parser.****ParserContext.getResult(**
>>>>> ParserContext.java:135)
>>>>> [java] at
>>>>> com.sun.xml.xsom.parser.****XSOMParser.getResult(****
>>>>> XSOMParser.java:211)
>>>>> [java] at
>>>>> com.sun.tools.xjc.ModelLoader.****createXSOM(ModelLoader.java:****532)
>>>>> [java] at
>>>>> com.sun.tools.xjc.api.impl.****s2j.SchemaCompilerImpl.bind(**
>>>>> SchemaCompilerImpl.java:268)
>>>>> [java] ... 16 more
>>>>> [java] Caused by: java.lang.reflect.****InvocationTargetException
>>>>> [java] at sun.reflect.****NativeMethodAccessorImpl.**
>>>>> invoke0(Native
>>>>> Method)
>>>>> [java] at
>>>>> sun.reflect.****NativeMethodAccessorImpl.****invoke(**
>>>>> NativeMethodAccessorImpl.java:****39)
>>>>> [java] at
>>>>> sun.reflect.****DelegatingMethodAccessorImpl.****invoke(**
>>>>> DelegatingMethodAccessorImpl.****java:25)
>>>>> [java] at java.lang.reflect.Method.****invoke(Method.java:597)
>>>>> [java] at
>>>>> org.apache.cxf.common.util.****ReflectionInvokationHandler.****
>>>>> invoke(**
>>>>> ReflectionInvokationHandler.****java:52)
>>>>> [java] ... 28 more
>>>>> [java] Caused by: java.lang.RuntimeException: Error compiling schema
>>>>> from WADL : undefined simple or complex type 'testCompositeObject'
>>>>> [java] at
>>>>> org.apache.cxf.tools.wadlto.****jaxrs.SourceGenerator$**
>>>>> InnerErrorListener.error(****SourceGenerator.java:1343)
>>>>> [java] ... 33 more
>>>>> [java] Caused by: org.xml.sax.SAXParseException: undefined simple or
>>>>> complex type 'testCompositeObject'
>>>>> [java] at
>>>>> com.sun.xml.xsom.impl.parser.****ParserContext$1.reportError(****
>>>>> ParserContext.java:180)
>>>>> [java] ... 23 more
>>>>>
>>>>>
>>>>> I should add though, if I just get the object like :
>>>>>
>>>>> @GET
>>>>> @Path("setTest2")
>>>>> @Produces("application/xml")
>>>>> public TestCompositeObject getTest2()
>>>>> {
>>>>> return(new TestCompositeObject());
>>>>> }
>>>>>
>>>>> It does return XML as a string like I expect it to.
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 10, 2012 at 7:15 PM, Sergey
>>>>> Beryozkin<[email protected]****
>>>>>
>>>>>> wrote:
>>>>>>
>>>>>
>>>>> Hi
>>>>>
>>>>>>
>>>>>> On 10/05/12 04:37, Ted wrote:
>>>>>>
>>>>>> thanks for the answer to my previous method Id problem, adding
>>>>>>
>>>>>>> addResourceAndMethodIds worked great.
>>>>>>>
>>>>>>> I have a new problem now, I'm trying to use the JAXB to automatically
>>>>>>> convert parameters and response types to and from java/xml. The
>>>>>>> method
>>>>>>> parameter seems to be dissappearing, or I'm missing an annotation or
>>>>>>> something. All the examples I've seen and documentation seems to show
>>>>>>> that
>>>>>>> it should work...
>>>>>>>
>>>>>>> My service has the following :
>>>>>>>
>>>>>>> @XmlRootElement
>>>>>>> public static class TestCompositeObject
>>>>>>> {
>>>>>>> public int id = 23;
>>>>>>> public String name = "asdf";
>>>>>>> }
>>>>>>>
>>>>>>> @PUT
>>>>>>> @Path("setTest3")
>>>>>>> @Produces("application/xml")
>>>>>>> @Consumes("application/xml")
>>>>>>> public TestCompositeObject setTest3(TestCompositeObject transfer)
>>>>>>> {
>>>>>>> logger.info(transfer);
>>>>>>> return(transfer);
>>>>>>> }
>>>>>>>
>>>>>>> The wadl generated looks a little off, it's missing the params :
>>>>>>>
>>>>>>> <resource path="/setTest3">
>>>>>>> <method name="PUT" id="setTest3">
>>>>>>> <request>
>>>>>>> <representation mediaType="application/xml" />
>>>>>>> </request>
>>>>>>> <response>
>>>>>>> <representation mediaType="application/xml" />
>>>>>>> </response>
>>>>>>> </method>
>>>>>>> </resource>
>>>>>>>
>>>>>>> As a result when I generate the stubs from the wadl, it comes out not
>>>>>>> quite
>>>>>>> right :
>>>>>>>
>>>>>>> @PUT
>>>>>>> @Consumes("application/xml")
>>>>>>> @Produces("application/xml")
>>>>>>> @Path("/setTest3")
>>>>>>> Response setTest3();
>>>>>>>
>>>>>>> There's no method parameter, and I'm not quite sure if Response
>>>>>>> should
>>>>>>> be
>>>>>>> the return type of if it should have been mapped back to
>>>>>>> TestCompositeObject.
>>>>>>>
>>>>>>> I can't seem to find any documentation on any annotations or any
>>>>>>> configuration to sort this out.
>>>>>>>
>>>>>>>
>>>>>>> The explanation is that TestCompositeObject has no any namespace
>>>>>>> bound
>>>>>>>
>>>>>> to
>>>>>> it, please add a namespace attribute to XMlRootElement and you
>>>>>> should get
>>>>>> the grammar and links properly generated
>>>>>>
>>>>>> HTH
>>>>>> Sergey
>>>>>>
>>>>>>
>>>>>> Anyone have any ideas?
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> Sergey Beryozkin
>>>>>>
>>>>>> Talend Community Coders
>>>>>> http://coders.talend.com/
>>>>>>
>>>>>> Blog: http://sberyozkin.blogspot.com
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>



-- 
Ted.

Reply via email to