Help! requested resource not available

G

garhone

Hi,
First, I have searched high and low for the solution to this problem
.... but have found nothing.
All I'm trying to do is to be able to see a simple JSP page:

web.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>false</param-value>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to validate the XML in your
faces-config.xml resources against the DTD. Default
value is false.
</description>
</context-param>

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
<description>
Comma separated list of URIs of (additional) faces config files.
</description>
</context-param>

<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>


<!-- Faces Servlet Mapping.
This mapping identifies a jsp page as having JSF content. If a
request comes to the server for foo.faces, the container will
send the request to the FacesServlet, which will expect a
corresponding foo.jsp page to exist containing the content.
-->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

<!--
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
-->

<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!--
Disallow direct access to the JSP pages that are
used for JSF. You must add a <url-pattern> entry
for each JSP page that corresponds to a faces page.
-->

<security-constraint>
<display-name>
Prevent access to raw JSP pages that are for JSF pages.
</display-name>
<web-resource-collection>
<web-resource-name>Raw-JSF-JSP-Pages</web-resource-name>

<!-- Add url-pattern for EACH raw JSP page -->
<url-pattern>/index.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>No roles, so no direct access</description>
</auth-constraint>
</security-constraint>

</web-app>
-----------------------------------------------------
index.jsp:
<!-- index.jsp -->

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Index</title></head>
<body>
<f:view>
<h2>This is a test</h2>
<p>
<h:eek:utputText value="Hello World" />
</p>
</f:view>
</body>
</html>
----------------------------------------------------------
faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config>
<!-- nothing relevant -->
</faces-config>
--------------------------------------------------------------
directory structure:
jsp/
index.jsp
WEB-INF/
classes/
faces-config.xml
lib/
web.xml
-----------------------------------------------------------
when I try to open http://hostname:port/app/faces/jsp/index.jsp
I get the 404 error: Requested resource is not available

Any help is appreciated, as I am going out of my mind!

Thanks,
C
 
O

Oliver Wong

garhone said:
Oliver said:
[snip configuration info]
when I try to open http://hostname:port/app/faces/jsp/index.jsp
I get the 404 error: Requested resource is not available

Any help is appreciated, as I am going out of my mind!

Well, let's start with the obvious... did you replace "hostname" and
"port" with your server's hostname (or IP address) and port number?

- Oliver

Yes, I did replace hostname and port with the appropriate values.

Does going to the root, i.e. http://hostname:port/, yield a non 404
page?

- Oliver
 
G

garhone

Oliver said:
garhone said:
Oliver said:
[snip configuration info]
when I try to open http://hostname:port/app/faces/jsp/index.jsp
I get the 404 error: Requested resource is not available

Any help is appreciated, as I am going out of my mind!

Well, let's start with the obvious... did you replace "hostname" and
"port" with your server's hostname (or IP address) and port number?

- Oliver

Yes, I did replace hostname and port with the appropriate values.

Does going to the root, i.e. http://hostname:port/, yield a non 404
page?

- Oliver

This yields the "Java Web Services Developer Pack 1.5" page.
 
O

Oliver Wong

garhone said:
Oliver said:
garhone said:
Oliver Wong wrote:
[snip configuration info]
when I try to open http://hostname:port/app/faces/jsp/index.jsp
I get the 404 error: Requested resource is not available
[...]

Does going to the root, i.e. http://hostname:port/, yield a non 404
page?

This yields the "Java Web Services Developer Pack 1.5" page.

So I'd suspect the problem is that the path /app/faces/jsp/index.jsp is
incorrect. Try incrementally moving down the path
(http://hostname:port/app/, http://hostname:port/app/faces/,
http://hostname:port/app/faces/jsp/, etc.) until you find the culprit.

- Oliver
 
G

garhone

Oliver said:
garhone said:
Oliver said:
Oliver Wong wrote:
[snip configuration info]
when I try to open http://hostname:port/app/faces/jsp/index.jsp
I get the 404 error: Requested resource is not available
[...]

Does going to the root, i.e. http://hostname:port/, yield a non 404
page?

This yields the "Java Web Services Developer Pack 1.5" page.

So I'd suspect the problem is that the path /app/faces/jsp/index.jsp is
incorrect. Try incrementally moving down the path
(http://hostname:port/app/, http://hostname:port/app/faces/,
http://hostname:port/app/faces/jsp/, etc.) until you find the culprit.

- Oliver

Hi,
So I tried this suggestion, and what happened with each progression is
that my browser would just hang for a very long time.

Anyways, I made a couple of changes before trying to call index.jsp
again:
I copied a faces-config.xml file (one I know works) over the existing
one and made the necessary modifications.
Also, I found out I had some phantom tomcat processes going on, which I
had killed.

I'm not sure if one, the other or both changes solved the problem.

The most frustrating part of this ordeal was the vague error message of
"Requested resource not available", along with the fact that I could
not find any remotely similar situation by googling or searching Sun's
forums (but that's not anyone else's fault but my own :p ).

If anyone out there has any "default" debugging tips for when
confronted with this error message (I mean, when you see "requested
resource not available", you know to try to look in a certain set of
areas to alleviate the problem), I would greatly appreciate it.

Finally, thanks Oliver for all your help. I am really grateful.

C.
 
O

Oliver Wong

garhone said:
The most frustrating part of this ordeal was the vague error message of
"Requested resource not available", along with the fact that I could
not find any remotely similar situation by googling or searching Sun's
forums (but that's not anyone else's fault but my own :p ).

If anyone out there has any "default" debugging tips for when
confronted with this error message (I mean, when you see "requested
resource not available", you know to try to look in a certain set of
areas to alleviate the problem), I would greatly appreciate it.

I don't think it would have solved your specific problem, but it might
be worthwhile to take a look at, and eventually memorize, some of the HTTP
status codes, as they're standardized:

http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
http://en.wikipedia.org/wiki/404_error

You'll see 404 and 500 so commonly, that it's hard not to memorize them.
404 means that a resource was not found (which is why I tried having you
verify the path), while 500 means "internal server error" which is the most
vague one of them all.

- Oliver
 
Joined
Aug 15, 2008
Messages
1
Reaction score
0
I had the same problem with the resource not found error message.

My mistake was that I typed an extra space in the <url-pattern> tag
like <url-pattern>*.faces </url-pattern> instead of <url-pattern>*.faces<url-pattern>

Bottom line: you have to be very carefull not to leave any extra spaces inside tags in these config files.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top