Mule / Maven错误:从元素'dw:transform-message'

时间:2017-03-06 01:31:24

标签: mule mule-studio munit

我正在尝试使用Maven运行一个项目,使用一个简单的测试类,但测试错误输出(没有失败!)并显示消息:

  

测试集:com.mycompany.myproject.testApiResponseNotNullTestCase

     

测试运行:1,失败:0,错误:1,跳过:0,经过的时间:4.423秒<<<失败! - 在com.mycompany.myproject.testApiResponseNotNullTestCase中   clientTestCase(com.mycompany.myproject.testApiResponseNotNullTestCase)经过的时间:3.084秒<<<错误!    org.mule.api.config.ConfigurationException:来自URL的XML文档中的第34行[file:/ C:/ Users / myuser / Documents /.../ dev / Mule%20Workspaces / myproject / myproject / target / test-classes / myproject.xml]无效;嵌套异常是org.xml.sax.SAXParseException; lineNumber:34; columnNumber:111; cvc-complex-type.2.4.a:从元素'dw:transform-message'开始发现无效内容。其中一个'{“http://www.mulesoft.org/schema/mule/core”:abstract-message-processor,“http://www.mulesoft.org/schema/mule/core”:abstract-outbound-endpoint,“http://www.mulesoft.org/schema/mule/core”:abstract-mixed-content-message-processor, “http://www.mulesoft.org/schema/mule/core”:响应,“http://www.mulesoft.org/schema/mule/core”:遗留抽象异常策略,“http://www.mulesoft.org/schema/mule/core”:abstract-message-info-mapping}'是预期的。 (org.mule.api.lifecycle.InitialisationException)   引起:org.mule.api.lifecycle.InitialisationException:来自URL的XML文档中的第34行[file:/ C:/ Users / myuser / Documents /.../ dev / Mule%20Workspaces / myproject / myproject / target / test -classes / myproject.xml]无效;嵌套异常是org.xml.sax.SAXParseException; lineNumber:34; columnNumber:111; cvc-complex-type.2.4.a:从元素'dw:transform-message'开始发现无效内容。

我已经尝试通过将以下内容添加到我的pom.xml

来解决此问题
<dependency>
   <groupId>com.mulesoft.weave</groupId>
   <artifactId>mule-plugin-weave</artifactId>
   <version>4.0.0-M4</version>
</dependency>

在“预期”之后提到的所有其他项目出现在模式中而dw:transform-message没有...这似乎很奇怪(或者可能完全如预期!?)但是这是Anypoint Studio生成的XML AFAIK。

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" 
	xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:context="http://www.springframework.org/schema/context" 
	xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" 
	xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns="http://www.mulesoft.org/schema/mule/core" 
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:spring="http://www.springframework.org/schema/beans" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
    <db:generic-config name="LocalDev_SqlServerConfig" url="jdbc:sqlserver://${mssql.server}:${mssql.port};databaseName=${mssql.database};user=${mssql.user};password=${mssql.password}" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" doc:name="Generic Database Configuration"/>

    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="${http.port}" basePath="/api" doc:name="HTTP Listener Configuration"/>
    <db:generic-config name="GenericMsSqlDbConnection" url="jdbc:sqlserver://${db.server}:${db.port};databaseName=${db.database};user=${db.user};password=${db.password}" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" doc:name="Generic Database Configuration"/>
    <context:property-placeholder location="main-${env}.properties"/>
    <flow name="mainFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP">
            <http:response-builder statusCode="200" reasonPhrase="OK"/>
            <http:error-response-builder statusCode="500" reasonPhrase="Internal server error"/>
        </http:listener>
        <set-property propertyName="currentDate" value="#[server.dateTime.getDayOfMonth() +&quot;/&quot;+ server.dateTime.getMonth() +&quot;/&quot; +server.dateTime.getYear()]" doc:name="Set Date Property"/>
        <set-property propertyName="hostname" value="#[server.host]" doc:name="Set Server Property"/>
        <logger message="Set property &quot;currentDate&quot; to #[message.outboundProperties.currentDate]" level="INFO" doc:name="Logger"/>
        <db:select config-ref="GenericMsSqlDbConnection" doc:name="Database">
            <db:parameterized-query><![CDATA[SELECT COUNT(*) AS OpportunityCount FROM vwOppsAnon1]]></db:parameterized-query>
        </db:select>
        <dw:transform-message metadata:id="480debf4-819f-4927-90ae-382a17489221" doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload map ((payload01 , indexOfPayload01) -> {
	opportunityCount: payload01.OpportunityCount,
	date: outboundProperties.currentDate as :string,
	server: outboundProperties.hostname
})]]></dw:set-payload>
        </dw:transform-message>
    </flow>
</mule>

3 个答案:

答案 0 :(得分:1)

org/xml/sax/SAXParseException.html基本上意味着项目的XML文档中缺少信息。

  

此异常可能包含用于查找错误的信息   原始XML文档,就好像它来自Locator对象。注意   虽然应用程序将收到SAXParseException作为   在ErrorHandler接口中的处理程序的参数,   应用程序实际上不需要抛出异常;代替,   它可以简单地读取其中的信息并采取不同的行动

错误堆栈跟踪清楚地读取它在你的情况下

  

引起:org.xml.sax.SAXParseException: cvc-complex-type.2.4.a:   找到以元素'dw:transform-message'

开头的无效内容

需要修复

  

来自URL的XML文档中的第34行   [文件:/ C:/用户/为myuser /文件/.../开发/骡%20Workspaces / myproject的/ myproject的/目标/测试类/ myproject.xml]

答案 1 :(得分:0)

在你的pom中添加这个依赖

 <dependency>
        <groupId>com.mulesoft.weave</groupId>
        <artifactId>mule-plugin-weave_2.11</artifactId>
        <version>${mule-version}</version>
</dependency>

答案 2 :(得分:0)

您必须添加与Mule Runtime版本匹配的精确版本。如果您的版本介于3.7.0和3.8.1之间,则需要添加:

<dependency>
        <groupId>com.mulesoft.weave</groupId>
        <artifactId>mule-plugin-weave_2.11</artifactId>
        <version>${mule-version}</version>
</dependency>

如果它大于3.8.1且小于4:

<dependency>
        <groupId>com.mulesoft.weave</groupId>
        <artifactId>mule-plugin-weave</artifactId>
        <version>${mule-version}</version>
</dependency>

对于4.0.0+,您不应添加任何内容。

不得添加与运行时版本不同的版本。您不是在升级DataWeave那样做,这将导致未定义和不受支持的行为。