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

标签 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 没有产生额外的有用信息——它是一个 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 .

最佳答案

尝试像这样使用 useEmitter 标签:

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

...

关于java - 为什么 axistools-maven-plugin 试图访问这个相对模式位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4781028/

相关文章:

java - 如何使用 SQL 查询结果作为 Java 中变量的值?

java - 将第 3 方 jar 包含在 Maven 阴影 jar 中而不将其添加到本地存储库

java - 使用 Hudson 进行 Maven 发布。发布成功,但 Hudson 保持红色

maven-2 - maven 条件依赖

java - 如何处理 Axis 1 客户端中的 HTTP 错误代码

java - 按值迭代 HashMap

java - 为什么 Java 中的多线程程序速度很慢,但不占用太多 CPU 时间?

java - 应用程序在 HttpResponse 上崩溃 httpResponse = httpClient.execute(httpGet);

java - 如何在java中调用axis apache客户端

java - Wsdl 可选参数在生成的 java stub 代码中成为强制参数