Wednesday, February 11, 2009

Mule 1.x: Spring Integration

Integrating a Spring configuration file into a Mule configuration has been the most frustrating thing in the world... well at least for me.

Mule provides documentation for using Spring with Mule 1.x in the following URL:

However, after following these instructions, there are a couple of things that were left undocumented for the spring application context xml to be integrated successfully. The following are these undocumented notes:

  1. The Spring application context xml file should not include a XML schema definition. It should specify the Mule-specific DTD.

    Example Spring XML:

    <beans xmlns="" xsi="" schemalocation="">


    In order for the Spring XML file to be read successfully by the Mule Server, the above Spring XML file must modified to use the DTD file, and not the XML Schema as follows:

    <!DOCTYPE beans PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN"

    If you do not do this, the Mule server will throw the following exception and cause you frustration beyond belief (jk):

    nested exception is org.xml.sax.SAXParseException: : XML-20149: (Error) Element 'beans' used but not declared.

  2. When specifying the <contianer-context> element, remember to define it at the appropriate place in the mule configuration xml.

    <!ELEMENT mule-configuration (description?,environment-properties?,mule-environment-properties?,container-context*,security-manager?,

    From the above DTD element, the container-context element should be after the mule-environment-properties element and before any connector, transformer, and model elements.

    If this is not the case, the Mule Server will throw the following exception:

    SAXParseException: : XML-20148: (Error) Invalid element 'container-context' in content of 'mule-configuration', expected elements '[connector, endpoint-identifiers, transformers, global-endpoints, interceptor-stack, model]'.

    It will indicate the mule-configuration DTD element that does not even contain the container-context element, which may be quite confusing.

So, it seems most of these are related to DTD and XML schema definitions.