views:

26

answers:

1

I created a webservice and would like to generate documentation for the API. So I looked into Enunciate downloaded the maven enunciate plugin. However I get the below error on compile as the webservice annotations are on my interface class that my POJO implements rather than the POJO itself.

I don't want to clutter the POJO by adding the annotations to it.  

    artifact org.mortbay.jetty:maven-jetty-plugin: checking for updates from central
[INFO] [enunciate:docs {execution: default}]
[INFO] initializing enunciate.
[INFO] invoking enunciate:generate step...
[WARNING] Validation result has errors.
/Users/vkumar/IdeaProjects/identity-service/trunk/src/main/java/com/foobar/ids/service/IDService.java:17: [jersey] Jersey doesn't support interfaces as root resources. 
The @Path parameter will need to be applied to the implementation class.

public interface IDService {
       ^
1 error
[INFO] ------------------------------------------------------------------------


The pom.xml snippet is here

        <plugin>
          <groupId>org.codehaus.enunciate</groupId>
          <artifactId>maven-enunciate-plugin</artifactId>
          <!-- check for the latest version -->
          <version>1.20</version>
          <executions>
            <execution>
              <goals>
                <goal>docs</goal>
              </goals>
              <configuration>

                <!-- the directory where to put the docs -->
                <docsDir>${project.build}/docs </docsDir>

              </configuration>
            </execution>
          </executions>
        </plugin>
A: 

That's a limitation of Jersey. You have to annotate your implementation class.

CXF, however, doesn't make that same requirement, so you may want to consider using the CXF implementation of JAX-RS instead of the Jersey implementation:

    <plugin>
      <groupId>org.codehaus.enunciate</groupId>
      <artifactId>maven-enunciate-cxf-plugin</artifactId>
      <!-- check for the latest version -->
      <version>1.20</version>
      <executions>
        <execution>
          <goals>
            <goal>docs</goal>
          </goals>
          <configuration>

            <!-- the directory where to put the docs -->
            <docsDir>${project.build}/docs </docsDir>

          </configuration>
        </execution>
      </executions>
    </plugin>
Ryan Heaton