DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Java
  4. Fixing Broken Windows #1: beans.xml Validation in Java EE 6

Fixing Broken Windows #1: beans.xml Validation in Java EE 6

Felipe Gaúcho user avatar by
Felipe Gaúcho
·
Feb. 12, 10 · Interview
Like (0)
Save
Tweet
Share
5.66K Views

Join the DZone community and get the full member experience.

Join For Free

CDI is one of the best features of Java EE 6, it gives you - for example - a chance to include a beans.xml file in the WEB-INF folder in order to optimize the beans discovering during the application startup. An empty file is a fair price to pay for the cool features of the CDI but as soon you import the project in your preferred IDE you will see warnings about the impossibility of validating such file. The IDE is doing its job mitigating the risk of work without a chance to validate an XML file, now it is your time to fix this broken window.

The beans descriptor schema: beans_1_0.xsd

If you mess with the beans.xml file and try to deploy your application, Glassfish V3 will identify the problem because it contains the schema document describing the format of the bean.xml file. You can find this schema in the folder $AS_HOME/glassfish/lib/schemas/beans_1_0.xsd, where $AS_HOME stands for the Glassfish V3 installation folder.


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 :)

 

UPDATE: please also vote in this other broken window: http://jira.codehaus.org/browse/MPWAR-74

From http://weblogs.java.net/blog/felipegaucho

Java EE Java (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Best Navicat Alternative for Windows
  • 19 Most Common OpenSSL Commands for 2023
  • Use AWS Controllers for Kubernetes To Deploy a Serverless Data Processing Solution With SQS, Lambda, and DynamoDB
  • Fixing Bottlenecks in Your Microservices App Flows

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: