Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beggining JSF: FaceletViewHandler

 
Valmir Cinquini
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:530)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18154
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Valmir Cinquini
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim

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:

web.xml

faces-config.xml:


 
Tim Holloway
Saloon Keeper
Pie
Posts: 18154
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a good intro to Facelets:

http://www.ibm.com/developerworks/java/library/j-facelets/

And the main site:

https://facelets.dev.java.net/

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic