Reputation: 163
I'm a beginner in Java. I'm using eclipse Helios and Tomcat 7.
I configured the server and wrote my first JSF page, but I got this error:
HTTP Status 404 - /
type Status report
message /
description The requested resource (/) is not available.
Apache Tomcat/7.0.27
The code of first page is this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>JSF 2.0 Hello World</title>
</h:head>
<h:body>
<h3>JSF 2.0 Hello World Example - hello.xhtml</h3>
</h:body>
</html>
I then changed the port to 8088. But when I type localhost:8088
in my browser, I get the same error.
Upvotes: 3
Views: 10100
Reputation: 635
Tomcat doesn't comes with jsf libs. Download the jsf lib file and place them inside \apache-tomcat\lib folder. rebuild project and restart server and you are good to go.
Upvotes: 6
Reputation: 29
you may have problems with your jsf libraries so try to put them in your lib folder under WEB-inf and then do so : right click on your project -->properties-->java build path-->JSF_lib-->remove in order to evoid any conflicts
Upvotes: 0
Reputation: 558
the way you are trying to do is wrong
In jsf when ever we type the url like "localhost:8088\faces\test.jsp" then first thing that happens is this url is parsed and if there conatins any url pattren which can initiate facesServlet then only jsf lifecycle starts
this url pattern has to in deployment descriptor( i.e. web.xml) now when you are trying to access it by localhost\8080\ facesservlet is not getting started so that is the reason for your error.
web.xml should have an entry like
Faces servlet *.xhtml
this will ensure that whenever your url have *.xhtml then your faces servlet cyscle will start.
if your web.xml has
<servlet-mapping> <servlet-name>Faces servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping>
then your url should have "faces" in your url. hope this helps. regards anil sharma
Upvotes: 0
Reputation: 2427
This can be caused by few common reasons :
Most likely beacuse you are trying to access something like this on startup: localhost:8080/MyProject/
To be able to do so you will have to specify welcome file list in your web.xml :
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
Also add these lines to specify servlet mapping if you already don't have so:
<servlet-mapping>
<servlet-name>Faces servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Make sure your index.xhtml file is in Web pages folder.
You have placed your .xhtml file you are trying to access somewhere outside of Wep pages folder.
You are trying to acces some .xhtml which doesn't exist.
I bet it's the first one because log error shows : resource (/), so you are probably trying to acces welcome file.
Hope it helped a bit !
Upvotes: 8