Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: OpenEntityManagerInViewFilter unnecessary for images

  1. #11
    Join Date
    Mar 2009
    Posts
    14

    Default

    Correction: as first filter, try UrlRewriteFilter, and then followed by OSIV filter.

  2. #12
    Join Date
    Mar 2009
    Posts
    14

    Default

    Code:
    <filter-mapping>
       <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
       <url-pattern>/app/*</url-pattern>
       <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    should be changed to

    Code:
    <filter-mapping>
       <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
       <url-pattern>/app/*</url-pattern>
       <dispatcher>REQUEST</dispatcher>  
       <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    Otherwise OSIV wil not work for direct requests that go to /app/* without the UrlRewriteFilter.
    This happens because of this Servlet spec rule:
    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.
    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.

  3. #13
    Join Date
    Sep 2009
    Posts
    101

    Default

    I needed to add FORWARD to my springSecurityFilterChain, too, which is defined after UrlRewriteFilter and OpenEntityManagerInViewFilter.

    Code:
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
    	    <dispatcher>REQUEST</dispatcher>
    	    <dispatcher>FORWARD</dispatcher>
        </filter-mapping>
    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:
    	@RequestMapping(value = "/appuser/task", method = RequestMethod.POST)    
        public String create(Authentication auth, @Valid Task task, BindingResult result, ModelMap modelMap) {
      //auth is null!!!

  4. #14
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    @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

  5. #15
    Join Date
    Sep 2009
    Posts
    101

    Default

    @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.

  6. #16
    Join Date
    Oct 2006
    Posts
    11

    Default

    I've just suggested an alternative setup in http://jira.springframework.org/browse/ROO-655.

    --dhukas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •