简体   繁体   English

在 Mule 4 模板中调用 Java 方法

[英]Invoke Java method in Mule 4 template

I'm trying to create Mule 4 service template and trying to invoke java method but getting below error:-我正在尝试创建 Mule 4 服务模板并尝试调用 java 方法,但出现以下错误:-

org.xml.sax.SAXParseException; org.xml.sax.SAXParseException; lineNumber: 26;行号:26; columnNumber: 140;列数:140; cvc-complex-type.2.4.a: Invalid content was found starting with element 'java:invoke-static'. cvc-complex-type.2.4.a:发现以元素“java:invoke-static”开头的无效内容。 One of '{" http://www.mulesoft.org/schema/mule/core ":abstract-message-processor, " http://www.mulesoft.org/schema/mule/core ":abstract-mixed-content-message-processor}' is expected. '{" http://www.mulesoft.org/schema/mule/core ":abstract-message-processor, " http://www.mulesoft.org/schema/mule/core ":abstract-mixed-之一预期内容消息处理器}'。

I've update the mule-artifact.json :-我已经更新了 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": {}
  }
}

Even I faced the same issue, may be some problem with Anypoint studio in generating the configuration xml.即使我遇到了同样的问题,Anypoint studio 在生成配置 xml 时也可能存在一些问题。 You can add the below namespaces and schemas locations to get rid of the error您可以添加以下命名空间和架构位置以消除错误


<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"> 

You need to add the Java Module to your pom.xml.您需要将 Java 模块添加到 pom.xml。 It is an optional module.它是一个可选模块。

Also if you use the last Mule Maven Plugin version (current is 3.3.1 I think) you can omit almost all of the mule-artifact.json and it will auto generated.此外,如果您使用最新的 Mule Maven 插件版本(我认为当前是 3.3.1),您可以省略几乎所有的 mule-artifact.json,它会自动生成。 Example of a minimal mule-artifact.json:最小 mule-artifact.json 示例:

{
  "minMuleVersion": "4.1.4",
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM