users@jersey.java.net

Re: impedance betweem hyperjaxb and jersey

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Wed, 1 Apr 2009 20:56:12 +0200

fixed!

I used a wrapper element to return the hyperjaxb generated types
through Jersey annotated resources, and it works:

the schema (fully compatible with hyperjaxb):

        <xsd:element name="configuration" type="config:footprint.config" />
        <xsd:complexType name="footprint.config">

the Jersey annotated method:

        @GET
        @Produces( { MediaType.APPLICATION_JSON })
        @Path("/test")
        public synchronized JAXBElement<FootprintConfig> test()
                        throws ServletException {
                try {
                        ObjectFactory factory = new ObjectFactory();
                        FootprintConfig config = factory.createFootprintConfig();
                        config.setIdiom("pt_BR");
                        return factory.createConfiguration(config);
                } catch (Exception oo) {
                        Logger.getLogger(Certificate.class.getName()).severe(
                                        oo.getMessage());
                        throw new ServletException(oo.getMessage());
                }
        }

and it works :)

thanks for all tips and tricks.. now my persistence layer is finally
exposed in the jersey endpoint (ops, resource in rest terminology)



2009/4/1 Felipe Gaúcho <fgaucho_at_gmail.com>:
> my latest trial - at least compile through hyperjaxb maven goal, but
> no sign of my RootElement :(
>
>        <xsd:annotation>
>                <xsd:documentation>
>                        Inspirational source:
>                        http://regexlib.com/Default.aspx
>                </xsd:documentation>
>                <xsd:appinfo>
>                        <jaxb:globalBindings>
>                                <xjc:serializable uid="-6908316602239211070" />
>                                <xjc:simple />
>                        </jaxb:globalBindings>
>                </xsd:appinfo>
>        </xsd:annotation>
>
>        <xsd:element name="Configuration">
>                <xsd:complexType>
>                        <xsd:annotation>
>                                <xsd:appinfo>
>                                        <jaxb:class name="footprint.config">
>                                        </jaxb:class>
>                                </xsd:appinfo>
>                        </xsd:annotation>
>                 ..........
>
>
> 2009/4/1 Felipe Gaúcho <fgaucho_at_gmail.com>:
>> 1) hyperjaxb doesn't support that:
>>
>>        <xsd:element name="configuration">
>>                <xsd:complexType>
>>                   .....
>>
>> console: Cannot derive a name from schema. A name attribute specified
>> to the <class> customization.
>>
>> 2) Jersey requires at least 1 root element, do not generated by the
>> below xsd fragment:
>>
>>        <xsd:element name="configuration" type="config:footprint.config" />
>>        <xsd:complexType name="footprint.config">
>>                .......
>>
>>
>> any solution for that ??
>>
>>
>> --
>>
>> Please help to test this application:
>> http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces
>>
>
>
>
> --
>
> Please help to test this application:
> http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces
>



-- 
Please help to test this application:
http://fgaucho.dyndns.org:8080/cejug-classifieds-richfaces