Just some more info... I copy and pasted from the cxf's sample basic
jax_rs, the CustomerService.java and Customer.java (and commented out the
Order.java references). I get the similar results.

    @PUT
    @Path("/customers/")
    public Response updateCustomer(Customer customer)
    {
    ...
    }

turns into

<method name="PUT" id="updateCustomer">
    <request>
        <representation mediaType="application/octet-stream"/>
    </request>
    <response>
        <representation mediaType="application/octet-stream"/>
    </response>
</method>

Is it my setup? My jaxrs:server declaration is

    <jaxrs:server id="restContainer" address="/rs">
        <jaxrs:serviceBeans>
            <ref bean="customerService"/>
         </jaxrs:serviceBeans>
        <jaxrs:providers>
            <!--
                <ref bean="jaxbProvider" />
            -->
            <bean class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
                <property name="addResourceAndMethodIds" value="true" />
            </bean>
        </jaxrs:providers>
    </jaxrs:server>

I've tried it with explicitly declaring the jaxbprovider and not, both have
the same results.



On Fri, May 11, 2012 at 8:34 AM, Ted <[email protected]> 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
>>
>
>
>
> --
> Ted.
>
>


-- 
Ted.

Reply via email to