简体   繁体   中英

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

org.xml.sax.SAXParseException; lineNumber: 26; columnNumber: 140; cvc-complex-type.2.4.a: Invalid content was found starting with element '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.

I've update the 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. 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. 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. Example of a minimal mule-artifact.json:

{
  "minMuleVersion": "4.1.4",
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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