I am using Spring MVC in my GAE application.
It appears to work very well in the classic form processing use case,
but the following scenario stumps me and would love to get ideas and
opinions on how to approach it:

I set up my own user authentication system and created several users
that exist in the datastore. The application is able to read them
successfully, locally and on GAE.

My views are stored in a 'standard' Spring file structure of /WEB-INF/
views and with a resolver set up as
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="prefix" value="/WEB-INF/views/"/>
                <property name="suffix" value=".jsp"/>
        </bean>

To ensure users are authenticated, I set up a Spring Interceptor (akin
to a Filter), which checks whether users have authenticated by looking
at the HTTP Session for their user id (typed Long). The interceptor is
applied on requests coming to any URL starting with /secure/**. It
appears to work successfully as well as it redirects requests that
have no id in their session back to the login page. This works on GAE
as well.

I created a login view, bound to a controller, taking the user's email
and password. Based on logs, it appears to work as well. Where the
problem lies, is in the next step. After successfully authenticating,
I redirect users to the main menu of the application, and that's where
things break and I get a 404 error.  All of this works fine in the
local SDK. Then you deploy to GAE and the login functionality
encounters issues.

I tried all of the following to exactly the same result, a 404 error:
1. Since the menu is a plain jsp requiring no controller, I user
<mvc:view-controller path="/secure/menu" view-name="/secure/menu"/>
where the jsp file is located at /WEB-INF/views/secure/menu.jsp
I receive a 404 error
2. Created a @Controller for the main menu, mapped to "/secure/main-
menu". The controller virtually does nothing, except log it received
the request. It then forwards the request to /secure/menu - and still
a 404 error.
3. I tried to have the @Controller redirect to /secure/menu - 404
error.

This called for a more extreme measure which ended up working:
To check whether the JSP is indeed around the WAR file, I tried
loading it using

ServletContext ctx = req.getSession().getServletContext();
ctx.getResourceAsStream("/WEB-INF/views/secure/menu.jsp");

The file loaded (avoiding full code), and if I output the text of the
file to the screen (using the @ResponseBody annotation) I shows up. So
in essence, the file is available, but for some reason Spring on GAE
is unable to find it.

I am using the URL Rewrite filter (http://code.google.com/p/
urlrewritefilter/) which appears to work successfully. I suspected
that the fact that following the initial login GAE uses
the ...;jsessionid=.... URL parameter and that causes the URL Rewrite
to fail, but my logs and tests show that my @Controller receives the
request.

What stumps me is why is the JSP file not being found or loaded? Why
am I getting the same 404 error on GAE?

As I said, it all works perfectly fine on my local SDK environment.

Thanks for any hints or ideas.



-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to