wood burning stoves
The moose likes JSF and the fly likes Beggining JSF: FaceletViewHandler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Beggining JSF: FaceletViewHandler" Watch "Beggining JSF: FaceletViewHandler" New topic

Beggining JSF: FaceletViewHandler

Valmir Cinquini

Joined: Nov 11, 2009
Posts: 26
Thanks for help me.

I'm following a sample code from a book about jsf. Different from the book, I'm using jboss 4.2.3.GA and netbeans 6.8 (the book sample uses tomcat and eclipse).

Everything works fine but there's one clause on the faces-config.xml that I have to comment, otherwise the code doesn't run:

When I uncomment the code above, I got the following error:

javax.servlet.ServletException: Error Parsing /form.jsp: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.

I had to remove jsf-api.jar and jsf-impl.jar from the netbeans project becouse they are already present in C:\jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\jsf-libs directory. If I don't, I got this error:

exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.jbossjsfconfigurelistener

Could someone explain me why these error occurs? And what is the purpose of the <view-handler> tag? The book doesn't explain that.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

The first error is self-describing. form.jsp is not well-formed. It has an error on line 1.
The second error is because your application server is already providing the needed jars.
If you are using maven to build your application you could change the dependency scope to provided for these jars.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17149

Your book probably didn't cover Facelets. The View Handler is telling Facelets to handle the Views instead of the default JSF View handler.

When you have an error on line 1 of an XML file, you probably didn't start it with the XML Processing Instruction:

With appropriate options, if any. You can get this error also if there if a line (even a blank line) preceeding the "*lt;?" or if it doesn't begin in column 1.

An IDE is no substitute for an Intelligent Developer.
Valmir Cinquini

Joined: Nov 11, 2009
Posts: 26

Yes, my book don't cover facelets. I'm looking for some tutorials on the net.

But both web.xml and faces-config.xml start with

here they are:



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17149

Here's a good intro to Facelets:


And the main site:


Google is good for stuff like that.

I'm not sure about the XML file error, since they look correct. But you might want to try putting the comment INSIDE the faces-config (root) element, instead of in front of it. In other words, right before the "managed-bean" element. XML can be fastidious sometimes.
I agree. Here's the link: http://aspose.com/file-tools
subject: Beggining JSF: FaceletViewHandler
It's not a secret anymore!