Why is axistools-maven-plugin trying to access this relative schema location?

Henrik Heimbuerger picture Henrik Heimbuerger · Jan 24, 2011 · Viewed 9.3k times · Source

We're doing a web service project with Axis 1.x and I'm having problems getting the Maven build to work.

I do a

 mvn clean generate-sources

which triggers axistools-maven-plugin's wsdl2java goal. It eventually aborts with

[INFO] [axistools:wsdl2java {execution: generate-project}]
[INFO] about to add compile source root
[INFO] Processing wsdl: C:\Project\src\main\webapp\WEB-INF\wsdl\project.wsdl
Jan 24, 2011 11:24:58 AM org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error generating Java code from WSDL.

Embedded error: Error running Axis
C:\Project\src\main\webapp\WEB-INF\project.xsd (The system cannot find the file specified)

This is correct. That file doesn't exist. (And -e yields no additional useful information -- it's a LifecycleExecutionException, caused by a MojoExecutionException, caused by an AxisPluginException, caused by a FileNotFoundException.)

The point is, it shouldn't search for WEB-INF\project.xsd, it should access WEB-INF\wsdl\project.xsd.

Here's what the WSDL says:

<wsdl:types>
    <xsd:schema targetNamespace="http://domain/project/">
        <xsd:import namespace="http://domain/schema/" schemaLocation="project.xsd"/>
    </xsd:schema>
</wsdl:types>

This seems to work fine for all my coworkers. We're all using Maven 2.2.1 and axistools-maven-plugin is pinned to 1.4 with the following configuration:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>axistools-maven-plugin</artifactId>
    <version>1.4</version>
    <executions>
      <execution>
        <id>generate-project</id>
        <goals>
          <goal>wsdl2java</goal>
        </goals>
        <configuration>
          <sourceDirectory>${basedir}/src/main/webapp/WEB-INF/wsdl/</sourceDirectory>
          <outputDirectory>target/generated-sources</outputDirectory>
          <serverSide>true</serverSide>
          <testCases>false</testCases>
          <wrapArrays>false</wrapArrays>
        </configuration>
      </execution>
    </executions>
  </plugin>

I already completely cleared my local Maven repository, hoping that it was a rogue dependency, but that didn't change anything. Any idea what could be causing this just for me, but not for my coworkers?


EDIT 1: I tried changing the schemaLocation to wsdl/project.xsd (just for testing purposes, I won't be able to make any permanent modifications to the WSDL) and got this amusing result:

Embedded error: Error running Axis
WSDLException (at /wsdl:definitions/wsdl:types/xsd:schema):
    faultCode=OTHER_ERROR: An error occurred trying to resolve
    schema referenced at 'wsdl\project.xsd', relative to
    'file:/C:/Project/src/main/webapp/WEB-INF/wsdl/project.wsdl'.:
    This file was not found:
    file:/C:/Project/src/main/webapp/WEB-INF/wsdl/wsdl/project.xsd

If you are, like me, now thinking that maybe ./project.xsd might work... nope, sorry, that makes it search directly for WEB-INF/project.xsd again.


EDIT 2: Okay, now axistools is just teasing me...

../project.xsd
--> src/main/webapp/project.xsd (wrong)

../wsdl/project.xsd
--> src/main/webapp/wsdl/project.xsd (wrong)

../WEB-INF/wsdl/project.xsd
--> src/main/webapp/WEB-INF/WEB-INF/wsdl/project.xsd (wrong)

As a reminder, the correct path would be src/main/webapp/WEB-INF/wsdl/project.xsd.

Answer

Bruno de Assis Marques picture Bruno de Assis Marques · Feb 9, 2011

Try to use the useEmitter tag like:

    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>axistools-maven-plugin</artifactId>
            <version>1.4</version>
            <configuration>
                <useEmitter>true</useEmitter>

...