当我尝试编译与包含单个代理的 ESB 项目相关的 .car 应用程序时,为什么会出现此 Maven 错误?

Why am I obtaining this Maven error when I try to compile a .car application related to an ESB project containing a single proxy?

我正在研究 VFS 概念,我正在尝试实现本教程: https://docs.wso2.com/pages/viewpage.action?pageId=87712181

但我对此有些疑惑:

使用此示例配置启动 ESB(如此处解释:https://docs.wso2.com/display/EI620/Setting+Up+the+ESB+Samples#SettingUptheESBSamples-Startingasample)它工作正常:

wso2ei-samples.bat -sn 254

基本上我的 PC 上有这个文件中定义的 254 示例:

C:\WSO2\EI.3.0\samples\service-bus\synapse_sample_254.xml

我认为用前面的-sn 253参数启动EI会执行这个流程。具体如何运作?我的想法是它将代理放入此文件 synapse_sample_254.xml 并在 EI 启动后自动部署它。但我完全不确定这个说法。

反正就是这样。

问题是我试图在创建代理的 ESB 项目中实现此行为,在这种情况下它不起作用。

我做了什么:

1) 我创建了一个 ESB 配置项目(名为 VFSTest)。

2) 在这个项目中我创建了一个 自定义代理 。新建 --> 代理服务 --> 创建一个新的代理服务。我将 "Proxy Service Name" 设置为 VFSProxy。然后我选择 Custom Proxy 作为 Proxy Service Type 下拉列表的值。这样我的新代理就创建好了。

3) 我为此代理插入以下代码(使用 Source 选项卡):

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <proxy name="StockQuoteProxy" startOnLoad="true" transports="vfs">
        <target>
            <endpoint>
                <address format="soap12" uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
            <inSequence/>
            <outSequence>
                <property expression="fn:concat(fn:substring-after(get-property('MessageID'), 'urn:uuid:'), '.xml')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/>
                <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
                <send>
                    <endpoint>
                        <address uri="vfs:file://C:\Users\nobil\OneDrive\Documenti\WSO2\RESOURCES\VFSTest\out"/>
                    </endpoint>
                </send>
            </outSequence>
            <faultSequence/>
        </target>
        <publishWSDL preservePolicy="true" uri="file:samples/service-bus/resources/proxy/sample_proxy_1.wsdl"/>
        <parameter name="transport.PollInterval">15</parameter>
        <parameter name="transport.vfs.FileURI">file://C:\Users\nobil\OneDrive\Documenti\WSO2\RESOURCES\VFSTest\in</parameter>
        <parameter name="transport.vfs.ContentType">text/xml</parameter>
        <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
        <parameter name="transport.vfs.MoveAfterFailure">file://C:\Users\nobil\OneDrive\Documenti\WSO2\RESOURCES\VFSTest\failure</parameter>
        <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
        <parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
        <parameter name="transport.vfs.MoveAfterProcess">file://C:\Users\nobil\OneDrive\Documenti\WSO2\RESOURCES\VFSTest\success</parameter>
    </proxy>
</definitions>

(我只是把之前示例中替换的与我PC上的目录和端点相关的同一行替换了,是相同的代码)。

所以现在我的 ESB 项目包含这个代理。

然后我创建一个名为 VFSTestCAP 的新 Composite Application Project 并添加之前的 VFSTest ESB 项目作为依赖项。

最后,我 select 这个 VFSTestCAP 项目的 pom.xml 文件,我做了一个 运行 As --> Maven Install 构建必须部署在我的服务器上的 .car 应用程序。

问题是这样做 Maven 失败了,这是我的堆栈跟踪:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building VFSTestCAP 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-resources-plugin/maven-metadata.xml
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-resources-plugin/maven-metadata.xml
[INFO] Downloading: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-resources-plugin/maven-metadata.xml
[INFO] Downloaded: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-resources-plugin/maven-metadata.xml (397 B at 0.3 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-resources-plugin/maven-metadata.xml (843 B at 0.6 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-resources-plugin/maven-metadata.xml (843 B at 0.6 KB/sec)
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml
[INFO] Downloading: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml (2 KB at 1.4 KB/sec)
[INFO] Downloaded: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml (402 B at 0.5 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml (2 KB at 1.3 KB/sec)
[INFO] Downloading: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml
[INFO] Downloaded: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml (491 B at 0.6 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml (2 KB at 2.0 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-surefire-plugin/maven-metadata.xml (2 KB at 2.0 KB/sec)
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml
[INFO] Downloading: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml
[INFO] Downloaded: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml (366 B at 0.5 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml (663 B at 0.8 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml (663 B at 0.8 KB/sec)
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
[INFO] Downloading: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
[INFO] Downloaded: http://dist.wso2.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml (394 B at 0.5 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml (749 B at 0.9 KB/sec)
[INFO] Downloaded: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml (749 B at 0.9 KB/sec)
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/com/example/VFSTest/proxy-service/VFSProxy/1.0.0/VFSProxy-1.0.0.pom
[INFO] Downloading: http://dist.wso2.org/maven2/com/example/VFSTest/proxy-service/VFSProxy/1.0.0/VFSProxy-1.0.0.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/example/VFSTest/proxy-service/VFSProxy/1.0.0/VFSProxy-1.0.0.pom
[WARNING] The POM for com.example.VFSTest.proxy-service:VFSProxy:xml:1.0.0 is missing, no dependency information available
[INFO] Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/com/example/VFSTest/proxy-service/VFSProxy/1.0.0/VFSProxy-1.0.0.xml
[INFO] Downloading: http://dist.wso2.org/maven2/com/example/VFSTest/proxy-service/VFSProxy/1.0.0/VFSProxy-1.0.0.xml
[INFO] Downloading: https://repo.maven.apache.org/maven2/com/example/VFSTest/proxy-service/VFSProxy/1.0.0/VFSProxy-1.0.0.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.597 s
[INFO] Finished at: 2018-10-12T11:21:42+02:00
[INFO] Final Memory: 20M/295M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project VFSTestCAP: Could not resolve dependencies for project com.example.VFSTestCAP:VFSTestCAP:carbon/application:1.0.0: Could not find artifact com.example.VFSTest.proxy-service:VFSProxy:xml:1.0.0 in wso2-nexus (http://maven.wso2.org/nexus/content/groups/wso2-public/) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

如您所见,错误似乎是:

[ERROR] Failed to execute goal on project VFSTestCAP: Could not resolve dependencies for project com.example.VFSTestCAP:VFSTestCAP:carbon/application:1.0.0: Could not find artifact com.example.VFSTest.proxy-service:VFSProxy:xml:1.0.0 in wso2-nexus (http://maven.wso2.org/nexus/content/groups/wso2-public/) -> [Help 1]

为什么要尝试从 Nexus 检索 VFSProxy?它在我的 ESB 项目中定义为 XML 流。

可能是什么问题?我错过了什么?我该如何修复它并创建我的汽车可部署应用程序?

首先,您必须像构建 capp 项目一样构建代理项目。现在,如果您尝试构建 capp,它会成功,因为相关的依赖项将在您的本地 maven 存储库中。

PS:如果要使用maven构建car文件,最好使用maven multi module project。这将首先安装工件,然后相应地安装 capp。否则,只需导出 capp 就足够了。

您为新代理提供的名称与您使用示例代理中的代码复制的名称可能不匹配(如您的 post 所示)。

当您生成新代理时,Eclipse 会自动在 artifacts.xml 文件中创建一个条目。如果名称与代理代码中的名称不同,则可能会在 Maven 尝试解析 CAR 项目的依赖项时导致问题。

检查这一点的最佳方法是将 pom 文件中的依赖项与 ESB 项目中的 artifacts.xml 进行比较。如果您更改名称,请确保您与实际代理定义中的名称相匹配(以防止将来混淆)