Overcoming XML Validation Errors in Eclipse 3.5

September 21 2009

24 comments 0
motif

When I recently switched to Galileo, I noticed that a Mule configuration file that had previously validated correctly now had validation errors. Since I did not change the file, something in Galileo’s validation of files must have changed.

The symptoms are these:

  • The very first line of the document has an error message saying “Referenced file contains errors” and mentions mule.xsd.
  • The model, service, and endpoint elements all have an error message saying that invalid content was found and that some other kind of element was expected.

After some googling, I found out that this is indeed related to Eclipse and not an error in the Mule configuration. The Xerces parser used by Eclipse’s WTP for parsing tries to resolve all namespaces referenced in the config file in all schemas.

Since Mule’s schemas are not split over multiple schema files, it’s safe to turn off this feature. In Eclipse’s preferences, go to XML > XML Files > Validation and clear the Honour all schema locations check box. Mule config files should now validate without errors again.

For details, see the issue in Eclipse’s bug tracker.


We'd love to hear your opinion on this post


24 Responses to “Overcoming XML Validation Errors in Eclipse 3.5”

  1. This post helped me a lot. Thanks!

  2. Hi Dirk,
    How were you able to install Mule IDE plugin for Eclipse Galileo. When I try to install plugin using update site http://dist.muleforge.org/mule-ide/updates/3.4/ I am not able to do that. My Galileo install in correct because I am able to install other plugins. Have you installed Mule IDE manually using zip files?

  3. Paras, Galileo’s software installation dialog has changed quite a bit and the existing update site doesn’t play too well with it.

    You may still install MuleIDE from it – if you know how 🙂 Add the Mule IDE site and in the following dialog, make sure that “Group items by category” is *not* checked. Then you will see the Mule IDE feature for installation.

  4. I am able to install the plugin. For others information – Please see http://forums.mulesoft.org/thread.jspa?messageID=5509

  5. Thanks for the tip. Very usefull!

  6. Thanks for the tip.
    I had to right click the xml-file and select Validate. Cleaning and Refreshing did not clean the errors after setting the Honour all schema locations off.

  7. Dirk, thanks for the post. I just switched over and was beginning to pull my remaining hair out, then finally found this.

  8. Thank you Dirk. I too had to validate the XML file after clearing the parameter.

  9. Dirk, thanks for the info. I’ve tried the suggestions on this forum but the problem persists.
    I’m running Eclipse Helios for Java Developers, trying to get the Mule Hello sample to work. I cleared the check box, rebuilt the project but the below error remains.
    Running the project from the command line works perfectly.
    New to Mule and the IDE, any help will be appreciated.

    Mule Console Output:
    INFO 2010-07-12 10:35:02,824 [main] org.mule.MuleServer: Mule Server initializing…
    INFO 2010-07-12 10:35:03,167 [main] org.mule.config.spring.MuleApplicationContext: Refreshing org.mule.config.spring.MuleApplicationContext@1ff0dde: display name [org.mule.config.spring.MuleApplicationContext@1ff0dde]; startup date [Mon Jul 12 10:35:03 CAT 2010]; root of context hierarchy
    ERROR 2010-07-12 10:35:03,980 [main] org.mule.config.spring.SpringXmlConfigurationBuilder: Configuration with “org.mule.config.spring.SpringXmlConfigurationBuilder” failed.
    org.mule.api.lifecycle.InitialisationException: Initialisation Failure: Line 34 in XML document from URL [file:/C:/muleworkspace/ToeMule2/conf/hello-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element ‘stdio:connector’. One of ‘{“http://www.springframework.org/schema/beans”:beans, ……… is expected.

  10. Dawie, it looks like Mule cannot find mule-transport-stdio.jar … When using Mule IDE do you have a valid Mule runtime configured?

  11. Thank you for the feedback. The jar (mule-transport-stdio-2.2.1.jar) appears in the ‘Mule Libraries’ folder of the demo project in the IDE, and it exists on disk so it should find it.
    When I run the project from the command line it works fine so it seems like an issue with Eclipse failing to validate the config file when launching via Run-As in the IDE.
    Right-click – Validate on the config file succeeds though.

  12. Got it going, copied jars from MULE_HOME/lib/endorsed to replace those in jre/lib/endorsed and it fixed the issue.
    Thank you for your time.

  13. Hello, thanks for the tip. However, this does not work for me, here is the error:

    “invalid content was found starting with element ‘role-name’ no child element is expected at this point”

    For your information, when i only put 1 ‘role-name’ there is no error, when i put a second one, this display the above error.

    Moreover, i’m using javaee.xsd and when I replace it by j2ee.xsd, the error disappears, but got a grammar warning on the xsd line … I want to still use version 2.5 using javaee.

    I’ve tried to invalid content was found starting with element ‘role-name’ no child element is expected at this point, but the error still appears …

    Any solution ?

  14. I’ve tried to clear the Honour all schema locations check box., but the error still appears …*

    (Sorry for mistake ^^)

  15. Thanks Dirk..it works..:)
    cheers, sagar

  16. Thanks for this post. I was having similar problem in Eclipse Helios and it got fixed now with your solution.

  17. Thanks for this post. I had the same problem with OxyGen XMl (which is also using the XerCes parser) for validating a mule 3.1 configuration file. Due to this post i solved the problem to uncheck a similar box.

  18. Hi Dirk,

    I have similar issue. I unchecked the box ” Honour all schema locations ” but still issue remain same.

    Please help me.
    Below is my error.

    JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException
    – with linked exception:
    [org.xml.sax.SAXParseException: cvc-complex-type.2.4.d: Invalid content was found starting with element ‘prod:SortColumn’. No child element is expected at this point.]

    org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException
    – with linked exception:
    [org.xml.sax.SAXParseException: cvc-complex-type.2.4.d: Invalid content was found starting with element ‘prod:SortColumn’. No child element is expected at this point.]

  19. Thanks for the information. This was a very irritating warning to have displayed all the time. I too had to manually “validate” the document before the error went away (even after a restart!). Bizarre.

    Perfect write up.

  20. […] default, Eclipse 3.5 will flag all sorts of spurious errors in your XML configuration file. See the blog post for more details, but here’s the short version on how to solve […]

  21. Oh thanks! That hint also works for Eclipse 3.7 (Indigo).

  22. Hello thanks for the tips, but it didn’t help me solving the problem, theses errors persists and I have no idea why… I am using Mule studio , the examples work fine but when I try to add an interceptor to the component nothing works…here is the erros if someone have any idea I will be so grateful … :

    cvc-complex-type.2.4.a: Invalid content was found starting with element ‘custom-interceptor’. One of {“http://www.mulesoft.org/schema/mule/core”:abstract-lifecycle-adapter-factory, “http://www.mulesoft.org/schema/mule/core”:binding}’ is expected. adding-logging-to-a-flow.xml /HelloExample/src/main/app line 11 XML Problem
    cvc-complex-type.2.4.a: Invalid content was found starting with element ‘custom-interceptor’. One of ‘{“http://www.mulesoft.org/schema/mule/core”:abstract-lifecycle-adapter-factory, “http://www.mulesoft.org/schema/mule/core”:binding}’ is expected. adding-logging-to-a-flow.xml /echoexample/src/main/app line 14 XML Problem
    cvc-complex-type.2.4.a: Invalid content was found starting with element ‘http:inbound-endpoint’. One of ‘{“http://www.mulesoft.org/schema/mule/core”:annotations, “http://www.mulesoft.org/schema/mule/core”:description, “http://www.mulesoft.org/schema/mule/core”:inbound, “http://www.mulesoft.org/schema/mule/core”:abstract-component, “http://www.mulesoft.org/schema/mule/core”:outbound, “http://www.mulesoft.org/schema/mule/core”:async-reply, “http://www.mulesoft.org/schema/mule/core”:abstract-exception-strategy, “http://www.mulesoft.org/schema/mule/core”:abstract-message-info-mapping, “http://www.mulesoft.org/schema/mule/core”:abstract-service-threading-profile, “http://www.mulesoft.org/schema/mule/core”:abstract-queue-profile}’ is expected. adding-logging-to-a-flow.xml /HelloExample/src/main/app line 8 XML Problem
    cvc-complex-type.2.4.a: Invalid content was found starting with element ‘http:inbound-endpoint’. One of ‘{“http://www.mulesoft.org/schema/mule/core”:annotations, “http://www.mulesoft.org/schema/mule/core”:description, “http://www.mulesoft.org/schema/mule/core”:inbound, “http://www.mulesoft.org/schema/mule/core”:abstract-component, “http://www.mulesoft.org/schema/mule/core”:outbound, “http://www.mulesoft.org/schema/mule/core”:async-reply, “http://www.mulesoft.org/schema/mule/core”:abstract-exception-strategy, “http://www.mulesoft.org/schema/mule/core”:abstract-message-info-mapping, “http://www.mulesoft.org/schema/mule/core”:abstract-service-threading-profile, “http://www.mulesoft.org/schema/mule/core”:abstract-queue-profile}’ is expected. adding-logging-to-a-flow.xml /echoexample/src/main/app line 9 XML Problem
    cvc-complex-type.2.4.a: Invalid content was found starting with element ‘service’. One of ‘{“http://www.mulesoft.org/schema/mule/core”:annotations, “http://www.mulesoft.org/schema/mule/core”:description, “http://www.mulesoft.org/schema/mule/core”:abstract-message-source, “http://www.mulesoft.org/schema/mule/core”:abstract-inbound-endpoint, “http://www.mulesoft.org/schema/mule/core”:abstract-message-processor, “http://www.mulesoft.org/schema/mule/core”:abstract-outbound-endpoint, “http://www.mulesoft.org/schema/mule/core”:response}’ is expected. adding-logging-to-a-flow.xml /HelloExample/src/main/app line 7 XML Problem
    cvc-complex-type.2.4.a: Invalid content was found starting with element ‘service’. One of ‘{“http://www.mulesoft.org/schema/mule/core”:annotations, “http://www.mulesoft.org/schema/mule/core”:description, “http://www.mulesoft.org/schema/mule/core”:abstract-message-source, “http://www.mulesoft.org/schema/mule/core”:abstract-inbound-endpoint, “http://www.mulesoft.org/schema/mule/core”:abstract-message-processor, “http://www.mulesoft.org/schema/mule/core”:abstract-outbound-endpoint, “http://www.mulesoft.org/schema/mule/core”:response}’ is expected. adding-logging-to-a-flow.xml /echoexample/src/main/app line 8 XML Problem
    Referenced file contains errors (jar:file:/C:/Documents and Settings/DSG/Desktop/MuleStudio/Software/MuleStudio/plugins/org.mule.tooling.ui.modules.core_1.3.0.201206220515.jar!/schemas/mule.xsd). For more information, right click on the message in the Problems View and select “Show Details…” adding-logging-to-a-flow.xml /HelloExample/src/main/app line 1 XML Problem
    Referenced file contains errors (jar:file:/C:/Documents and Settings/DSG/Desktop/MuleStudio/Software/MuleStudio/plugins/org.mule.tooling.ui.modules.core_1.3.0.201206220515.jar!/schemas/mule.xsd). For more information, right click on the message in the Problems View and select “Show Details…” adding-logging-to-a-flow.xml /echoexample/src/main/app line 1 XML Problem

  23. Thank you very much.
    I was stucked with this error, you saved me!