Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Help! requested resource not available

Thread view: 
garhone - 05 Sep 2006 21:58 GMT
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:outputText 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
Oliver Wong - 05 Sep 2006 22:01 GMT
[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
garhone - 05 Sep 2006 22:08 GMT
> [snip configuration info]
> > when I try to open http://hostname:port/app/faces/jsp/index.jsp
[quoted text clipped - 6 lines]
>
>     - Oliver

Yes, I did replace hostname and port with the appropriate values.
Oliver Wong - 05 Sep 2006 22:10 GMT
>> [snip configuration info]
>> > when I try to open http://hostname:port/app/faces/jsp/index.jsp
[quoted text clipped - 8 lines]
>
> 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
garhone - 05 Sep 2006 22:51 GMT
> >> [snip configuration info]
> >> > when I try to open http://hostname:port/app/faces/jsp/index.jsp
[quoted text clipped - 13 lines]
>
>     - Oliver

This yields the "Java Web Services Developer Pack 1.5" page.
Oliver Wong - 06 Sep 2006 15:37 GMT
>> >> [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
garhone - 06 Sep 2006 23:34 GMT
> >> >> [snip configuration info]
> >> >> > when I try to open http://hostname:port/app/faces/jsp/index.jsp
[quoted text clipped - 13 lines]
>
>     - 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.
Oliver Wong - 07 Sep 2006 17:01 GMT
> The most frustrating part of this ordeal was the vague error message of
> "Requested resource not available", along with the fact that I could
[quoted text clipped - 5 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.