Announcement Announcement Module
Collapse
No announcement yet.
Has anyone succeeded using OpenViewInSessionFilter/Interceptor with sitemesh ?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Has anyone succeeded using OpenViewInSessionFilter/Interceptor with sitemesh ??

    Hello Good People!!

    Excuse me if this line of questions has been asked over and over again. In fact i've read a good deal of them and learnt from it. I have posted a lot on stackoverflow and wanted to have expertise from here as well.

    I am using spring 3.0.5, hibernate 3.6.1 , sitemesh 2.4.2. right now my dispatcher application context and my config application context are separated after reading this link. I've used OpenSessionInViewFilter on the web.xml and i still have LazyInitialization exception i've also tried using the OpenSessionInViewInterceptor in the config application context. I'm currently out of otpion. i've seen some other hacking solutions but i wanted to find you from people using spring mvc everyday and sitemesh what seems to make this so stubborn and complicated.

    Thanks for reading this
    Last edited by highjo; Feb 25th, 2012, 06:17 AM.

  • #2
    Anyone? please

    Comment


    • #3
      Used it on several occasions together without any problems. My guess your Sitemesh filter is before your OSIV filter which closes the session before sitemesh can do its thing.

      You want the OSIVF to be the FIRST filter in the chain.

      Comment


      • #4
        THanks for replying , that makes sense , i've tried the interceptor too, does the same implication happen?

        Comment


        • #5
          The interceptor is executed inside the dispatcherservlet so as soon as the request leaves the servlet the session is closed. As stated you really need the filter and it needs to execute as the first filter (or at least BEFORE the SiteMesh filter).

          Comment


          • #6
            Hello , i've tried your suggestion, and definitely there is something am not doing well because am still having a Lazy initialization exception. posted web.xml,application context config(myproject-web-config.xml), application context model (myprojet-model-config.xml), application context mvc (myproject-servlet.xml).


            i moved OSIVF just after the dispatcher section and its url mapping is "/" while sitemesh filters from "/site/*" we use zk for
            our admin, so basication we use spring for url rewriting and return the view zk mvc takes over from there. and it from this mapping "/admin/*" the files can be viewed on pastie
            thanks

            Comment


            • #7
              Filter should be mapped to /* not /...

              Comment


              • #8
                I have cleared my tomcat conf, and work specific folder of my project on tomcat, performed that change, clean and built the app again and still having the same exception

                Comment


                • #9
                  How are you working with the session you aren't opening sessions yourself are you? Also you aren't storing entities in the session for later usage as that isn't a usecase supported by the OSIVF.

                  Comment


                  • #10
                    No, we are using GenericDAO, and we wired the sessionFactory to the GenericDAO and call getCurrentSession each time, there is a database operation involved. And all database operation are done in the service layer with @transaction on top.
                    here is how the GenericDAO is configured

                    Comment


                    • #11
                      Originally posted by Marten Deinum
                      Also you aren't storing entities in the session for later usage as that isn't a usecase supported by the OSIVF.
                      Judging from the stacktrace it looks like you are retrieving something in the first request and try to add/store something in a second request (see my previous comment). This might be unknowningly, there seem to be quite a lot of servlets/listeners/filters involved.

                      Comment


                      • #12
                        Sorry for the late answer, i wasn't sent to this page when i click on the link in my email.
                        Ok that particular exception is for a the recent case where am trying to update an object. that exception is thrown when trying to set both side of an bidirectional association with helper method.
                        Also you aren't storing entities in the session for later usage as that isn't a usecase supported by the OSIVF.
                        am not sure i understand this very well, DO you mean storing in httpsession as used in php/asp? or specifically something with Hibernate session ?

                        am still checking the code to see if we are doing that

                        Comment


                        • #13
                          am not sure i understand this very well, DO you mean storing in httpsession as used in php/asp? or specifically something with Hibernate session ?
                          I meant the first storing in HttpSession (maybe unknowningly).

                          Updating the object where does the object you want to update come from do you retrieve it from the database, the same goes for the object you want to add to the collection.

                          Comment


                          • #14
                            Hello!!

                            Yes we are using HttpSession for passing Data, and we use apache shiro for security layer too,
                            and know shiro has it's session built on top of the HttpSession and am not sure how it uses the HttpSession.

                            Yes the object comes from the database and in this scenario, we are adding a child to its collection by using a helper method, to add both side of the association (bidirectional).

                            What options do i have then, it can be complicated not to use the HttpSession at all, any idea? some things can't be passed as querystring.
                            thanks again

                            Comment

                            Working...
                            X