users@jersey.java.net

[Jersey] Re: Need extended wadl help

From: Gerard Davison <gerard.davison_at_oracle.com>
Date: Mon, 08 Aug 2011 13:18:31 +0100

Christopher,

You might find things a little simpler if your mime type is
"application/my-widget+xml" as Jersey will know how to deal with JAX-B
elements. (Look at the class
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider.App) You
shouldn't have to write individual writers and readers.

Also if you are using JAX-B then in 1.9 I have added a feature to
automatically generate the Schema types and links at run type, look in
the forum history for an emails titled "New Feature: Automatic
Generation of XML Schema form JAX-B element".

Of course you might be be using JAX-B beans and are not able to move up
to 1.9,

Gerard


On 23/12/2010 16:38, Christopher Piggott wrote:
> I have a number of resources that return various XML objects. It
> would be nice if the wadl indicated the real return types, so, in an
> attempt to be clever, I created mime types for each of my xml root
> objects, then set up resources to
> @Produce("application/xml-my-widget").
>
> This made the WADL look good, but jersey wanted me to create a unique
> MessageBodyWriter for each one of those objects. Both the server and
> client get messy.
>
> I think the answer to this is extended wadl and provide a
> @resource.xxx.representation for each one of these. So that's what
> I'm attempting to do.
>
> I have not been able to piece together a working maven configuration
> for this. If I understand correctly then what I really need to is to
> configure maven-javadoc-plugin to use resource-doclet, which should
> cause it to produce a file
> ${project.build.outputDirectory}/resourcedoc.xml that contains hints
> to the extended wadl generator at runtime. (Correct?)
>
> I am using 1.4 for now. In my dependencies I load:
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-server</artifactId>
> <version>1.4</version>
> </dependency>
> as well as a number of other pieces (jersey-guice, etc.)
>
> What I can't figure out is why when I go to build I get this:
>
> "An error has occurred in JavaDocs report generation:Unable to find
> artifact:groupId = 'com.sun.jersey' artifactId = 'jersey-server'
> version = '1.4'"
>
> Obviously, jersey-server is there because the rest of the project
> builds just fine. It's in my local .m2 repository, everything looks
> AOK.
>
>
>
>
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-javadoc-plugin</artifactId>
> <executions>
> <execution>
> <goals>
> <goal>javadoc</goal>
> </goals>
> <phase>compile</phase>
> </execution>
> </executions>
> <configuration>
> <encoding>UTF-8</encoding>
> <verbose>false</verbose>
> <show>public</show>
> <subpackages>com.sun.jersey.samples.generatewadl.resources</subpackages>
>
> <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>
> <docletArtifacts>
> <docletArtifact>
> <groupId>com.sun.jersey.contribs</groupId>
> <artifactId>wadl-resourcedoc-doclet</artifactId>
> <version>1.4</version>
> </docletArtifact>
> <docletArtifact>
> <groupId>com.sun.jersey</groupId> <!-- *** This is
> where it is broken? *** -->
> <artifactId>jersey-server</artifactId>
> <version>1.4</version>
> </docletArtifact>
> <docletArtifact>
> <groupId>xerces</groupId>
> <artifactId>xercesImpl</artifactId>
> <version>2.6.1</version>
> </docletArtifact>
> </docletArtifacts>
> <additionalparam>-output
> ${project.build.outputDirectory}/resourcedoc.xml</additionalparam>
> <useStandardDocletOptions>false</useStandardDocletOptions>
> </configuration>
> </plugin>

-- 
Gerard Davison | Senior Principal Software Engineer | +44 118 924 5095
Oracle JDeveloper Web Service, Spring, Weblogic SCA Tooling Development
Oracle Corporation UK Ltd is a company incorporated in England&  Wales.
Company Reg. No. 1782505.
Reg. office: Oracle Parkway, Thames Valley Park, Reading RG6 1RA.
Blog http://kingsfleet.blogspot.com Twitter kingsfleet