Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I start a web application on an xhtml page?

 
Alejandro Barrero
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning RichFaces, but I cannot run a test application starting with echo.xhtml. In my web.xml I have as a welcome file index.html with

In my web.xml file I have

The suffix jsf should identify the pages in the application. However the browser displays with URL http://localhost:8080/Echo/ and an error message
The requested resource () is not available.
It cannot find a page with the name echo.jsf.

Your help will be greatly appreciated,

Alejandro Barrero
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alejandro,

I think the application is finding for a file with default extension i.e., .jsp file.
change the default suffix to .xhtml and run the application.

 
Alejandro Barrero
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Suresh, but it didn't work. Do you have a web.xml that works for you?
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also need to configure the facelets view handler in faces-config, because jsf comes by default with jsp.


And change your jsf servlet url pattern to *.xhtml
 
Alejandro Barrero
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Nick, but still it doesn't work. I copied the project from http://www.ibm.com/developerworks/web/library/j-richfaces/. The project's war file runs fine, but I had the same error in Eclipse and JBoss Developer studio. After I added <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>, faces-config.xml is

web.xml is
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here is your problem, you need to change it to *.xhtml. Also in your forwarding page, forward to a .xhtml page.

Nevermind that, it should work with .jsf too.

Post the stack trace that you get in your server logs.
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I think you'll get an error here, so better remove it, since you'ce already configured a view handler.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's generally a problem getting the server to invoke JSF (or Struts) pages directly from web.xml specs. This applies to not only the welcome page, but also to things like the login/loginfail pages. The reason has to do with the fact that internal requests don't set up all the necessary infrastructure to properly invoke the FacesServlet.

You can get around this by making the welcome page be a standard JSP with a redirect to the JSF welcome page on it.
 
Alejandro Barrero
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, but I must be doing something else wrong. In my case the input is index.html.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alejandro Barrero wrote:Thanks Tim, but I must be doing something else wrong. In my case the input is index.html.


Never let it be said that I can't miss the obvious. But can your fetch the echo.jsf page directly? If not, you've got a JSF problem. If you can, the problem is with the welcome page.
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We use an html page that forwards to jsf in our project, so he definitely does something wrong, it's not a jsf issue (at least not in jsf 1.2). The server logs will need to be checked out.
 
Alejandro Barrero
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message in the web page is The requested resource () is not available.

I don't get anything in the Tomcat log.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic