Fixing Broken Windows #1: beans.xml validation in Java EE 6
|
CDI is one of the best features of Java EE 6, it gives you - for example - a chance to include a The beans descriptor schema:
|
Including the proper header in your beans.xml file
The only step you need to proceed in order to calm down your IDE is to include the schema declaration in the header of the beans.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> </beans>
Done, just rebuild and refresh the project to see all that boring warnings going away. IMHO it is much more elegant than disabling the XML validation - what is commonly suggested by people that like to brake windows and/or software :)
IMPORTANT: it only works with a recent version of the Glassfish plugin for Eclipse (>= 1.0.52), so if your Eclipse installation is older than February 2010 it is a good moment to download the latest Eclipse IDE and install the Glassfish Plugin again, isn't it? This issue will disappear naturally with time, but it is an important detail since the plugin is too new.
* Thanks Ludo for all hints about this little issue.
* Thanks Dominik Dorn for calling my attention to a file I believed only available in the Glassfish distribution :)
- Printer-friendly version
- felipegaucho's blog
- 2513 reads






Comments
possible NPE
by cheeser - 2010-02-12 09:59
When I tried having an empty document as opposed to an empty file, i would get an NPE in BeansXmlParser. Are you not seeing this when you deploy your app?the valid document deploys fine
by felipegaucho - 2010-02-18 02:22
no, no problem here.. can you review your document ?
you can find an example of my deployable descriptor is here: http://kenai.com/projects/puj/sources/arena/show/arena-jsf20/src/main/webapp/WEB-INF