【问题标题】:Mule API Kit not available on 3.6.1 CE server?Mule API Kit 在 3.6.1 CE 服务器上不可用?
【发布时间】:2015-07-02 14:18:33
【问题描述】:

我有一个 Mule 项目,它通过 Mule Apikit 使用 REST API。 当我从 Eclipse 将项目作为“Mule 应用程序”运行时,没有任何问题。

当我将项目作为“带有 Maven 的 Mule 应用程序”运行时,应用程序会构建,但在 mule 服务器启动时,我看到与解析 apikit 架构和稍后在我的流程中的命名空间有关的错误。 (当我将应用程序加载到独立的 Mule 服务器时,我看到了同样的情况。

org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mule/apikit/current/mule-apikit.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

我的 .pom 文件中有两个与 apikit 相关的条目。

<dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-apikit</artifactId>
        <version>1.6.1</version>
    </dependency>

            <plugin>
                <groupId>org.mule.tools.maven</groupId>
                <artifactId>mule-app-maven-plugin</artifactId>
                <version>${mule.tools.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <copyToAppsDirectory>true</copyToAppsDirectory>

                <inclusions>
                        <inclusion>
                            <groupId>org.mule.modules</groupId>
                            <artifactId>mule-module-apikit</artifactId>
                        </inclusion>
                    </inclusions>
                </configuration>
            </plugin>

【问题讨论】:

  • mule-module-apikit-1.6.1.jar 是否正确打包在应用程序 zip 中,/lib 下?
  • 不,我已经尝试明确设置依赖关系的范围(编译和运行时都不包括它)。我还可以确认它在我的本地 .m2 目录中,因此查找 jar 没有问题。

标签: maven mule


【解决方案1】:

默认情况下,Mule Maven 插件会排除所有 Mule 依赖项,无论其范围如何。

您需要强制包含 APIkit 依赖项:

<configuration>
    <inclusions>
        <inclusion>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-module-apikit</artifactId>
        </inclusion>
    </inclusions>
</configuration>

参考:https://github.com/mulesoft/maven-mule-plugin/tree/maven-mule-plugin-1.9#managing-dependencies

【讨论】:

  • 在我的情况下,我确实包含(请参阅我的问题中带有 .pom 详细信息的第二个代码块),但 apikit jar 仍未复制。我已经为这个问题添加了一个答案,概述了在短期内为我解决了什么问题。
  • 让我们尝试其他方法:尝试将&lt;excludeMuleDependencies&gt;false&lt;/excludeMuleDependencies&gt; 添加到configuration 元素。
  • 刚刚测试过,结果相同 - 生成的 zip 不包含 lib 目录。
  • 等等,我的立场是正确的。我在错误的 mule 插件上进行了该配置(您可以在上面看到我在 mule-app-maven-plugin 上拥有它,但它应该在 maven-mule-plugin 上)。这对我有用。
【解决方案2】:

这个插件似乎是罪魁祸首:

        <plugin>
            <groupId>org.mule.tools</groupId>
            <artifactId>maven-mule-plugin</artifactId>
            <version>1.9</version>
            <extensions>true</extensions>
        </plugin>   

当它存在时,生成的 zip 中的 lib 目录不会被填充,当它被移除时,apikit(和其他库)会存在。

但是,这有副作用,这个插件似乎允许识别 /app/ 目录(我的项目正在使用)的子文件夹中的流 xml 文件。添加/删除依赖项似乎也会影响 eclipse 项目(我已经看到它删除了我所有的 src 文件夹并用单个 /src/ 替换它们)。

【讨论】:

  • fwiw,我想保留子文件夹结构(我怀疑没有 maven-mule-plugin 并不是真正的长期解决方案)-
  • 您有没有找到更好的解决方案来解决这个问题?
  • 不怕,这并不是说没有解决办法,只是我有一段时间没在 Mule 工作了,所以没有进一步调查的动力。
  • ...doh,看看接受的答案和其中的 cmets 看起来我确实解决了这个问题(公平地说是一年前)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-23
  • 1970-01-01
  • 2017-11-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多