0

I'm hitting the error "No support yet for multidimensional arrays" when running docs goal for maven plugin enunciate. Is there a way I can avoid it bombing out the process (ie. generate the rest of the docs for the API)?

I've tried @org.codehaus.enunciate.doc.ExcludeFromDocumentation on the API method returning the class with double array. I've tried @org.codehaus.enunciate.XmlTransient on the class with the double array.

I have since seen in enunciate documentation where those only affect whether they display on docs, not compilation.

I'm happy to hear any ideas you have!

Thanks.

Edit: The best I could do was dump project to temp directory, rip out all modules that aren't necessary to reach the api, delete the class with double array, and replace that part of the REST api's java method signature with String. This allows me to at least create the api document page via enunciate and give a description via javadoc. But, I'd love to have a more elegant solution, so please share if you know of one :)

Edit 2: Example pom:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.company.services.rest.service</groupId>
 <artifactId>service-rest-api</artifactId>
 <packaging>pom</packaging>
 <version>1.1</version>
 <name>service  REST API</name>
 <dependencies>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>2.2.1.GA</version>
      </dependency>
      <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>jaxrs-api</artifactId>
        <version>2.2.1.GA</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson-provider</artifactId>
        <version>2.2.1.GA</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxb-provider</artifactId>
        <version>2.2.1.GA</version>
        <exclusions>
          <exclusion>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-multipart-provider</artifactId>
        <version>2.2.1.GA</version>
      </dependency> 
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>tjws</artifactId>
        <version>2.2.1.GA</version>
      </dependency>
  </dependencies>
  <build>
    <plugins>
     <plugin>
       <groupId>org.codehaus.enunciate</groupId>
       <artifactId>maven-enunciate-plugin</artifactId>
       <version>1.26</version>
       <configuration>
         <forceWarPackaging>false</forceWarPackaging>
         <configFile>/tmp/enunciate-work/enunciate.xml</configFile>
       </configuration>
       <executions>
         <execution>
           <goals>
             <goal>docs</goal>
           </goals>
         </execution>
       </executions>
     </plugin>
    </plugins>
  </build>

Files located src/main/java/com/company/services/user/rest:

package com.company.services.service.rest;

import javax.ws.rs.POST;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;

@Path("/")
public interface ServiceResource {
    @POST
    @Path("/statuschanges")
    @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
    public ServiceStatusChanges getServiceStatusChangeLogs(String string);
}

package com.company.services.service.rest;

import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class ServiceStatusChanges implements Serializable {
    private static final long serialVersionUID = 1l;
    private String[][] logs;
    public ServiceStatusChanges() {}

    public ServiceStatusChanges(String[][] logs) {
        this.logs=logs;
    }

    public String[][] getLogs() {
        return logs;
    }

    public void setLogs(String[][] logs) {
        this.logs=logs;
    }
}

enunciate.xml:

<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="
           http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">

  <modules>
      <disable-rule id="csharp.warnings"/>
      <disable-rule id="c.warnings"/>
      <disable-rule id="obj-c.warnings"/>
          <docs docsDir="api" title="REST API" includeDefaultDownloads="false" disableRestMountpoint="true">

    </docs>
    <!-- Disable all the client generation tools -->
    <basic-app disabled="true" />
    <c disabled="true" />
    <csharp disabled="true" />
    <java-client disabled="true" />
    <jaxws-client disabled="true" />
    <jaxws-ri disabled="false" />
    <jaxws-support disabled="false" />
    <jersey disabled="true" />
    <obj-c disabled="true" />
    <xml forceExampleJson="true"/>
    <jaxws disabled="false"/>
    <amf disabled="true"/>
  </modules>

</enunciate>
4
  • Without the pom of the project nor more details it's hard to guess what's wrong.
    – khmarbaise
    Aug 17, 2012 at 21:06
  • Ok, I've added a simple sample project that demonstrates the known behavior I'm trying to circumvent.
    – Ben Rose
    Aug 20, 2012 at 4:56
  • Why do you have a configuration file located outside the Maven project? Looks strange to me..
    – khmarbaise
    Aug 20, 2012 at 6:56
  • If you're asking about enunciate.xml, it's used for the enunciate maven plugin.
    – Ben Rose
    Aug 21, 2012 at 14:43

2 Answers 2

0

If you don't need the XML support on that method, you could just do JSON and remove the @XmlRootElement annotation after removing the MediaType.APPLICATION_XML from the @Consumes and @Produces.

If you'd still like to support the XML, you could do some enhancements to support serialization-only changes such as making the logs property XML transient and wrapping the array as serialization time. This would have the additional benefit of Enunciate being able to document it instead of some out-of-band documentation. E.g.:

@XmlRootElement
public class ServiceStatusChanges implements Serializable {
    private static final long serialVersionUID = 1l;
    private String[][] logs;
    public ServiceStatusChanges() {}

    public ServiceStatusChanges(String[][] logs) {
        this.logs=logs;
    }

    @XmlTransient
    public String[][] getLogs() {
        return logs;
    }

    public void setLogs(String[][] logs) {
        this.logs=logs;
    }

    @XmlElement( name = "logs" )
    public Log[] getLogsWrapped() {
        Log[] logs = new Log[this.logs.length];
        //iterate through the logs and wrap it...
        return logs;
    }
}

And your Log class might look like:

@XmlRootElement
public class Log implements Serializable {
    @XmlValue
    public String value;
}
0

Enunciate docs generation survived when i used List<String[]> type instead of String[][]. As far as i remember generated JSON/XML examples and xsd seemed problematic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.