为什么axistools-maven-plugin试图访问这个相对模式位置?

时间:2011-01-24 10:40:38

标签: java maven-2 axis wsdl2java

我们正在使用Axis 1.x做一个Web服务项目,我在使Maven构建工作时遇到了问题。

我做了

 mvn clean generate-sources

触发axistools-maven-plugin的wsdl2java目标。它最终以

中止
[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)

这是对的。该文件不存在。 (并且-e不会产生额外的有用信息 - 它是由MojoExecutionException引起的LifecycleExecutionException,由AxisPluginException引起,由FileNotFoundException引起。)

关键是,它不应搜索WEB-INF\project.xsd,而是应该访问WEB-INF\wsdl\project.xsd

以下是WSDL的说法:

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

这对我的所有同事来说似乎都很好。我们都使用Maven 2.2.1,axistools-maven-plugin固定为1.4,配置如下:

  <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>

我已经完全清除了我的本地Maven存储库,希望它是一个流氓依赖,但这并没有改变任何东西。知道是什么原因造成这种情况只是为了我,而不是我的同事吗?


编辑1:我尝试将schemaLocation更改为wsdl/project.xsd(仅用于测试目的,我将无法对WSDL进行任何永久性修改)并获得了这个有趣的结果:

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

如果你像我一样,现在想可能./project.xsd可能会有效......不,抱歉,这会让它再次直接搜索WEB-INF/project.xsd


编辑2:好的,现在axistools只是在取笑我......

../project.xsd
   - &GT; src/main/webapp/project.xsd(错误)

../wsdl/project.xsd
   - &GT; src/main/webapp/wsdl/project.xsd(错误)

../WEB-INF/wsdl/project.xsd
   - &GT; src/main/webapp/WEB-INF/WEB-INF/wsdl/project.xsd(错误)

提醒一下,正确的路径是src/main/webapp/WEB-INF/wsdl/project.xsd

4 个答案:

答案 0 :(得分:7)

尝试使用useEmitter标记,如:

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

...

答案 1 :(得分:1)

不幸的是,启用<useEmitter><subPackageByFileName>功能不再有效。

所以我不得不将一代人分成两个“执行”

  • 首先是没有XSD和<subPackageByFileName>true</subPackageByFileName>
  • 的所有WSDL
  • 然后带有XSD的那个包含(幸运的是我只有一个)<useEmitter>true</useEmitter>(并且文件名明确添加到<packageSpace>

答案 2 :(得分:0)

我能够通过确保项目位置的路径不包含空格来解决此问题。因此,Win XP上的默认位置将不起作用(“文档和设置”)

答案 3 :(得分:0)

我在使用maven构建时也遇到了同样的问题,并且我能够通过确保项目位置的路径不包含空格来解决此问题。