【问题标题】:Invoke Java method in Mule 4 template在 Mule 4 模板中调用 Java 方法
【发布时间】:2019-01-13 21:52:45
【问题描述】:

我正在尝试创建 Mule 4 服务模板并尝试调用 java 方法但出现以下错误:-

org.xml.sax.SAXParseException;行号:26;列号:140; cvc-complex-type.2.4.a:发现以元素“java:invoke-static”开头的无效内容。需要 '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}' 之一。

我已经更新了 mule-artifact.json :-

{
  "configs": [
    "implementationservice.xml","globals.xml"
  ],
  "secureProperties": [],
  "redeploymentEnabled": true,
  "name": "implementationservice",
  "minMuleVersion": "4.1.4",
  "requiredProduct": "MULE_EE",
  "classLoaderModelLoaderDescriptor": {
    "id": "mule",
    "attributes": {
      "exportedResources": [],
      "exportedPackages": ["Utilities.systemInfo"]
    }
  },
  "bundleDescriptorLoader": {
    "id": "mule",
    "attributes": {}
  }
}

【问题讨论】:

  • 听起来您的配置或 java 模块中没有 java 命名空间。你能分享你的骡子配置xml吗?

标签: mule mule-component


【解决方案1】:

即使我遇到了同样的问题,Anypoint studio 在生成配置 xml 时也可能存在问题。您可以添加以下命名空间和架构位置以消除错误

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:java="http://www.mulesoft.org/schema/mule/java" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/java http://www.mulesoft.org/schema/mule/java/current/mule-java.xsd"> 

【讨论】:

    【解决方案2】:

    您需要将 Java 模块添加到您的 pom.xml。它是一个可选模块。

    此外,如果您使用最新的 Mule Maven 插件版本(我认为当前是 3.3.1),您可以省略几乎所有的 mule-artifact.json,它会自动生成。 最小的 mule-artifact.json 示例:

    {
      "minMuleVersion": "4.1.4",
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-20
      • 2022-01-28
      • 1970-01-01
      • 2013-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多