Results 1 to 6 of 6

Thread: sring & hibernate session factory problem

  1. #1
    Join Date
    Apr 2005
    Posts
    3

    Default sring & hibernate session factory problem

    Hi!

    Does spring manage LocalSessionFactoryBean in some kind weak reference, because if my application is idle sometime, it creates it again..
    The problem is, that in hibernate make this transaction lookup factory for level 2 cache, and it takes LOT time, bootup can take about 40 seconds, and that isn't good thing..
    I cannot understand why it takes so much time, actually funny thing is, that it takes so much time only our product server, where we have dual processor..

    So, is there some way to prevent losing reference to session factory?

    Thanks already.

    - Artsi

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Turn logging on and see what's going on with the FactoryBean. You can also look at the sources of Spring to see if it uses a weak references. I would say on your server you have some kind of aggressive GC that recycles objects very fast.
    For HB you can improve startup performance by serializing the configuration and then loading it - it's out of the box in HB3 and on the CVS (I think) for HB 2.1. See this page:http://www.hibernate.org/194.html
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Apr 2005
    Posts
    3

    Default

    Hi!

    Yes i have read sources.. and i cannot find nothing special..

    There is other program on same server, where we have self coded this hibernate stuff, creating SessionFactory and there everything works fine.
    Main difference is that in that application SessionFactory is maintained in class's static reference and it is created in startup, and it lives until process is terminated.

    The problem is that i really cannot reboot server all the time to resolve this feature, and like i said, i have encouter this problem only this one machine, and only this machine has dual processor.. has anyone test this combination on dual platform?!??

    This 40%-60% speedup is not sufficient..

  4. #4
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Quote Originally Posted by artsi
    Hi!

    Yes i have read sources.. and i cannot find nothing special..

    There is other program on same server, where we have self coded this hibernate stuff, creating SessionFactory and there everything works fine.
    Main difference is that in that application SessionFactory is maintained in class's static reference and it is created in startup, and it lives until process is terminated.

    The problem is that i really cannot reboot server all the time to resolve this feature, and like i said, i have encouter this problem only this one machine, and only this machine has dual processor.. has anyone test this combination on dual platform?!??

    This 40%-60% speedup is not sufficient..
    Where and how do you load your applicationContext?

  5. #5
    Join Date
    Apr 2005
    Posts
    3

    Default

    It's a web application. i use spring's MVC model.. I use dispatcher servlet. hm.. so.. and after all ( best one =)) i have extends spring's Dispatcher Servlet, and i implement SingleThreadModel in subclass... =) So is it so that every thread create new application context?!? =)

    oh dear.. =)

    Any hints what is correct way to do this? i think that i need this single thread model, because web application does some really heavy weight stuff and request's will take some time.. should i use ContextLoaderListener? i think that it will fix this..

  6. #6
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Quote Originally Posted by artsi
    It's a web application. i use spring's MVC model.. I use dispatcher servlet. hm.. so.. and after all ( best one =)) i have extends spring's Dispatcher Servlet, and i implement SingleThreadModel in subclass... =) So is it so that every thread create new application context?!? =)

    oh dear.. =)

    Any hints what is correct way to do this? i think that i need this single thread model, because web application does some really heavy weight stuff and request's will take some time.. should i use ContextLoaderListener? i think that it will fix this..
    Long time you need to process your requests is not really a reason to use the single thread model. If your servlets are threadsafe (no instance variables is a good sign), and they should be, there's no reason whatsoever to use it.

Similar Threads

  1. OpenSessionInView and portlet support
    By garpinc2 in forum Web Flow
    Replies: 31
    Last Post: Apr 9th, 2010, 11:12 AM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  4. Replies: 3
    Last Post: Oct 1st, 2004, 03:56 AM
  5. Replies: 9
    Last Post: Sep 25th, 2004, 12:35 PM

Posting Permissions

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