Feb 1st, 2006, 10:12 AM
SessionFactory Closed !!! during web service invocation
"Professional Java Development using Spring Framework"
"Spring in Action"
"Spring Reference shipped with the framework archive"
I am trying to expose a business function using Axis. My setup follows,
As documented in books,
I have created a layer of DAO interfaces and the correspoding implementations (BookDaoImpl and UserDaoImpl). corresp beans are (bookDao and userDao)
I have created a layer of Business Objects (Service Layer) (UserServiceImpl and BookServiceImpl) corresp beans are (bookService and userService). These objects are proxied since I am using hibernateTransactionManager (I have tried jdbcTransactionManager and no transaction manager combinations too...)
I have created a business object JaxRpcBookService which has a method
Book getBookById(String id)
this bean obtains a "bookService" bean in its init method, and I delegate the above function to the bookService bean.
I have included the axis servlet as documented in the book "Professional Java Development using Spring Framework" in web.xml, as per my knowledge axis is properly configured since wsdl is avaliable with the said method exposed.
NOW I have written a client for invoking the above method, I started tomcat in debug mode "./catalina.sh debug" so that i could read the messages. Using some stdout statements I understood that the call goes upto the DAO and then an exception is thrown saying that the owning sessionFactory was closed. Ofcourse the infamous
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
Exception is thrown
I have tried several combinations of transaction managers, but this issue still remains
Somebody please help!!!
Thanks in advance!!!
PS: There is a pattern "Open Session in View", I think it may solve the problem, but i dunno how to register an interceptor
Last edited by aishvaryapedgaonkar; Feb 1st, 2006 at 10:26 AM.
Feb 3rd, 2006, 10:06 PM
Open Session in View should fix this. It's a servlet filter that you setup in your web.xml. Please consult the JavaDoc or Spring reference manual. There is TONS of information on it and it's very simple to setup.
Feb 4th, 2006, 12:15 PM
thanks a lot for replying
i've solved the problem, it was related to lazyloading. Apparantly you cannot use lazyloading over remote connections i.e webservices