【问题标题】:Why is axistools-maven-plugin trying to access this relative schema location?为什么axistools-maven-plugin 试图访问这个相对模式位置?
【发布时间】:2011-06-14 10:34:11
【问题描述】:

我们正在使用 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 不会产生额外的有用信息——它是 LifecycleExecutionException,由 MojoExecutionException 引起,由 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
--> src/main/webapp/project.xsd(错误)

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

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

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

【问题讨论】:

  • 你试过 mvn clean generate-sources 吗?
  • @Raghuram:是的,这就是我实际在做的事情。我会将其编辑到问题中。
  • 您是否为 SO 编辑了项目目录名称?我认为如果路径中有空格会出现此问题.. Win XP 上的常见
  • @Martin 项目名称肯定是经过编辑的。我不记得原始路径中是否有任何空格,但我相当确定我在一个简化的(阅读:接近根目录,没有空格)目录上明确尝试过它。我还认为路径中的空格会导致不同的行为和其他错误消息。

标签: java maven-2 axis wsdl2java


【解决方案1】:

尝试使用 useEmitter 标签,例如:

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

...

【讨论】:

  • 很难说使用这个标志的含义是什么。文档非常稀少——只有this,它没有提到发射器与命令行 wsdl2java 工具的不同之处。不过,它似乎确实解决了原始问题。谢谢!
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    很遗憾,当&lt;useEmitter&gt; 启用时,&lt;subPackageByFileName&gt; 功能不再起作用。

    所以我不得不将生成分为两个“执行”

    • 首先是所有没有 XSD 和 &lt;subPackageByFileName&gt;true&lt;/subPackageByFileName&gt; 的 WSDL
    • 然后是带有 XSD 的包含(幸运的是我只有一个)带有 &lt;useEmitter&gt;true&lt;/useEmitter&gt;(以及明确添加到 &lt;packageSpace&gt; 的文件名)

    【讨论】:

      【解决方案4】:

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

      【讨论】:

        猜你喜欢
        • 2012-12-24
        • 1970-01-01
        • 1970-01-01
        • 2011-12-09
        • 1970-01-01
        • 2010-10-08
        • 1970-01-01
        • 2012-02-16
        • 2014-06-23
        相关资源
        最近更新 更多