Search code examples
jakarta-eejava-ee-6glassfish-3

Glassfish FileNotFoundException on First Load


I've created a simple login test setup using form-based authentication (using JSF). I have both a login.jsf page and an error.jsf page to redirect to on login failure. Now, in the tutorial I'm following (the book is Java EE 6 Development with Netbeans 7), they initially created both pages with the same login items in them, and then later cleaned up the rework issue by using a JSF Segment with the login form inside of it.

When I had no JSF Segment, the login setup worked perfectly. Since adding the JSF Segment and changing both pages to use it, I receive a 500 Internal Server error, with a FileNotFoundException relating to whatever page I'm using, but only the first time! If I refresh the page after receiving this error, it works.

This is the segment in question:

<!-- loginform.jspf -->
<%@ page pageEncoding="UTF-8" %>
   <p>Please enter your username and password:</p>
    <form method="POST" action="j_security_check">
        <table border="1">
            <tbody>
                <tr>
                    <td>Username:&nbsp;</td>
                    <td><input type="text" name="j_username" value="" /></td>
                </tr>
                <tr>
                    <td>Password:&nbsp;</td>
                    <td><input type="password" name="j_password" value="" /></td>
                </tr>
            </tbody>
        </table>
        <input type="submit" value="Login" />
    </form>

Since I've made this change, I've tried reverting back to simply having both pages contain separate versions of the same form, but still with no luck.

This is an example of the exception Glassfish throws on first load of one of the pages:

Glassfish Error

If you need me to upload more of the source code for troubleshooting, just say so in the comments and I'll post it (I didn't want this question to be flooded with source code unless it was necessary).

Thanks for your time!

EDIT: One quick thing I've noticed. Even after letting Glassfish load for awhile, the first time any page is accessed, I still receive this exception.


Solution

  • I've managed to figure out what was going on. Apparently the JSP deployment folders down in glassfish/domains//generated/jsp were owned by root, and this somehow made the items inside inaccessible for the first run. I'm still not sure why it would then let me access the pages after a refresh, but chowning the entire glassfish install resolved the issue for me.

    The issue was related to an exception I found in the server logs:

    "The scratchDir you specified: /home/bitwise/glassfish3/glassfish/domains/
    bitwise/generated/jsp/securedsimplewebapp is unusable."
    

    So if anyone is having similar exceptions, check to make sure that you're the OWNER of the glassfish installation.