Contact Us 1-800-596-4880

Troubleshooting XML Module - Mule 4

To troubleshoot XML module, become familiar with the information about enabling verbose logging and interpreting commonly thrown messages.

Enable Verbose Logging

To get a better understanding of why an application’s interaction with the XML Module is failing, temporarily enable verbose logging for XML module.

Remember to always disable the enhanced verbosity after troubleshooting because it affects your Mule application performance.

To enable verbose logging:

  1. Access Anypoint Studio and navigate to the Package Explorer view.

  2. Open your application’s project name.

  3. Open the src/main/resources path folder.

  4. Open the log4j2.xml file inside the folder.

  5. Add an <AsyncLogger> tag inside the <Loggers> tag:

    			<Loggers>
    				...
    				<AsyncLogger name="org.mule.module.xml" level="DEBUG"/>
    				...
    			</Loggers>
  6. Save your application changes.

  7. Click the project name in Package Explorer and then click Run > Run As > Mule Application.

Troubleshoot Validation Against Schema Issues

When using the XML module to validate against a schema that has references to other local schema files, the validation can fail with the error:

The supplied schemas were not valid. schema_reference: Failed to read schema document schemadocumentname.xsd, because file access is not allowed due to restriction set by the accessExternalSchema property

In the Studio Console, the error looks like this:

ERROR 2021-03-25 18:42:34,499 [[MuleRuntime].uber.03: [bug-xsd-schema-not-found-support].bug-xsd-schema-not-foundFlow.CPU_INTENSIVE @52ec9ec0] [processor: ; event: 026a10a0-8db3-11eb-80a6-3c22fb270222] org.mule.runtime.core.internal.exception.DefaultSystemExceptionStrategy:
********************************************************************************
Message               : The supplied schemas were not valid. schema_reference: Failed to read schema document 'schemadocumentname.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
Element               : bug-xsd-schema-not-foundFlow/processors/2 @ bug-xsd-schema-not-found-support:main.xml:16 (Validate schema)
Element DSL           : <xml-module:validate-schema schemas="ref/despatchAdviceMessages/despatchAdviceMessage.xsd"></xml-module:validate-schema>
Error type            : XML-MODULE:INVALID_SCHEMA
FlowStack             : at bug-xsd-schema-not-foundFlow(bug-xsd-schema-not-foundFlow/processors/2 @ bug-xsd-schema-not-found-support:main.xml:16 (Validate schema))
  (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

This error occurs because the access was restricted in the XML module global element configuration by setting the Expand entities field to the default value of NEVER. This value prevents XXE (XML External Entity) and DoS (Denial of Service) attacks.

To resolve this issue, set the Expand entities field to INTERNAL:

  1. In Studio, open your project and access your Mule app flow.

  2. Navigate to the Global Element tab.

  3. Select the XML Config configuration and click Edit.

  4. In the Global Element Properties window, set the Expand entities field to INTERNAL.

  5. Click OK.

XML module global configuration Expand entities field

In the Configuration XML editor, the <expandEntities> configuration looks like this:

<xml-module:config name="XML_Config" expandEntities="INTERNAL"/>

Understand Common Throws

Here is a list of common throw messages and how to interpret them:

  • XML-MODULE:INVALID_INPUT_XML

    The input document is not a valid XML.
  • XML-MODULE:INVALID_SCHEMA

    The supplied schema is invalid.
  • XML-MODULE:INVALID_XPATH_EXPRESSION

    The supplied XPath expression is invalid.
  • XML-MODULE:NULL_CONTEXT_PROPERTY

    A context property with a null value was supplied.
  • XML-MODULE:SCHEMA_NOT_HONOURED

    The input XML document does not honor its schema.
  • XML-MODULE:SCHEMA_NOT_FOUND

    The schema could not be found.
  • XML-MODULE:TRANSFORMATION

    There was an error transforming an XML document.
  • XML-MODULE:SCHEMA_INPUT_ERROR

The Validate schema operation failed because both the Schema and the Schema Content fields were used at the same time during the operation’s execution. You can only use one of these fields to validate schema XSD content.

View on GitHub