Skip to main content

Add an XSD file to Eclipse and Eliminate Those Pesky XML Warnings

Posted by cayhorstmann on July 21, 2009 at 8:27 AM PDT

If you work with Eclipse and JSF 2, you too may be annoyed at the little
that shows up next
to all your faces-config.xml files (even those that are blessedly

Here is how you can get rid of them, and add autocompletion to faces-config
editing as well, in case they aren't empty after all. (Most of mine contain a
single element, to specify a resource bundle. Eliminating that would be a nice
item for convention-over-configuration in JSF 2.1).

  1. Download the source code for JSF 2 from href="">
  2. Make a directory such as ~/xsd and copy all files with
    extension .xsd from
    mojarra-version-sources/jsf-api/doc into that
    directory (so you can remove the source later)
  3. In Eclipse, locate a faces-config.xml and copy the entry from
    the xsi:schemaLocation attribute. You'll need it in the
    clipboard for step 5.
  4. Select WindowPreferences
    XMLXML Catalog.

  5. Select Add and fill in the dialog as shown below. Pick
    the .xsd file by clicking on File System and
    navigating to the directory in which you saved the files. Change the
    Key Type to Schema Location. Paste in the key.

  6. Rebuild your project. The warning-icon.png
    should be gone.

This also works for other XML schemas (such as the one for facelet tag
library descriptors).


Good one

Useful tip! Thanks. Now i can get auto complete working for xml which refer to my local xsd in the workspace

Eclipse bug?

Hi, I need to know if this is me or Eclipse itself having a bug... I registered this new schema as you describe and I am playing with a simple web app that has a faces-config.xml using the 2.0 schema and 1 managed-bean defined...
On the name of the managed-bean, Eclipse is emitting this validation error:

Description Resource Path Location Type cvc-id.3: A field of identity constraint 'faces-config-managed-bean-name-uniqueness' matched element 'faces-config', but this element does not have a simple type. faces-config.xml HelloFacelet/WebContent/WEB-INF line 7 XML Problem
The same faces-config using the 1.2 schema does not expose this error...

It's hard to tell without

It's hard to tell without seeing your faces-config.xml. I no longer have managed beans in my faces-config files :-) I just put in a bogus one. Autocompletion worked, and I didn't get an error.

new Java EE 6 schemas now in the GlassFish Plugin

Hi Cay,
When we push our GlassFish plugin 1.0.34 for Eclipse soon (next week?) all the new EE 6 schemas (including the new faceconfig and many others) will be automatically declared to Eclipse so that you do not need to do this manual step anymore...


hi Dr. Horstmann, I am your student from Software Engineering, CS160, SJSU fall. I was trying to be involved in open source projects to keep up the learning process and may perhaps develop something a new. Will you suggest where I should start with since learning Blackberry Application Development was challenging but quite interesting. sincerely, Prakash Shiwakoti SJSU