Correction: as first filter, try UrlRewriteFilter, and then followed by OSIV filter.
Correction: as first filter, try UrlRewriteFilter, and then followed by OSIV filter.
should be changed toCode:<filter-mapping> <filter-name>Spring OpenEntityManagerInViewFilter</filter-name> <url-pattern>/app/*</url-pattern> <dispatcher>FORWARD</dispatcher> </filter-mapping>
Otherwise OSIV wil not work for direct requests that go to /app/* without the UrlRewriteFilter.Code:<filter-mapping> <filter-name>Spring OpenEntityManagerInViewFilter</filter-name> <url-pattern>/app/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>
This happens because of this Servlet spec rule:
Which means that REQUEST is used by default, but when another <dispatcher> element exists other than REQUEST, than REQUEST won't be enabled by default.1) The request comes directly from the client.
This is indicated by a <dispatcher> element with value REQUEST,
or by the absence of any <dispatcher> elements.
I needed to add FORWARD to my springSecurityFilterChain, too, which is defined after UrlRewriteFilter and OpenEntityManagerInViewFilter.
Without adding "FORWARD", I believe I was getting NullPointerExceptions when using "authentication" injection in my controller methods. E.g. in the below snippet, "auth" would be null:Code:<filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>
Code:@RequestMapping(value = "/appuser/task", method = RequestMethod.POST) public String create(Authentication auth, @Valid Task task, BindingResult result, ModelMap modelMap) { //auth is null!!!
@mikej
Can you please add your springSecurityFilterChain setup as a comment to http://jira.springframework.org/browse/ROO-655 as well. This way we won't overlook it once we investigate this further.
Thanks for your help.
Stefan
Stefan Schmidt
Software Engineer, Spring Roo
SpringSource - a division of VMware
twitter @schmidtstefan
@Stefan,
I apologize but I can't replicate this now. I was responding to a suggestion on the thread that we put UrlRewriteFilter first in our filter-mapping chain. I believe my issue may have been related to a lazily loaded list being called during authentication. But I'm unsure enough that I don't want to muddy the waters.
I'll just add a couple of "things to test" on the issue.
I've just suggested an alternative setup in http://jira.springframework.org/browse/ROO-655.
--dhukas