Re: LazyInitializationException

2010-10-29 Thread Maurizio Cucchiara
It's hibernate thing (I guess db connection timeout). What's your DB? mysql? 2010/10/29 cellterry : > > Dear all, > > I encountered LazyInitializationException today in my SSH project today as > follows. > LOG4J<<< 1 2010-10-29 17:37:42,454 [http-8080-2] ERROR > org.hibernate.LazyIniti

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
> I think that this solution should be added somewhere in that Struts 2 + > Spring 2 + JPA + AJAX application example, because a lot of people will have > the same problem. The right order is already in the example, you made simple mistypo ;-) Best regards -- Lukasz http://www.lenart.org.pl/ -

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, I moved it and now it works!! Great man, thank you very very much! I hope that everything else will work good with this pattern ;-). No, my Acegi is not using JPA, it uses just basic (applicationContext-acegy-security.xml) configuration. I think that this solution should be added som

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
Move OpenEntityManagerInViewFilter mapping before Struts2 mapping like below Spring OpenEntityManagerInViewFilter /* struts2 /* If Acegi also use JPA. move OpenEntityManagerInViewFilter to the top. Regards -- Lukasz http://www.lenart.org.pl/ --

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, this is my web.xml http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";> Person contextConfigLocation

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, sorry about this amount of messages. I actually do this (because of deleting): Person person= service.getEntityManager().getReference(Person.class, id); and then, when I do this: session.lock( person, LockMode.NONE); I get: org.hibernate.SessionException: Session is closed!

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
2008/6/27 Milan Milanovic <[EMAIL PROTECTED]>: > > Hi Lukasz, > > great, thanks! > > Yes, I put this new mapping to my web.xml and now my application works. But > again when I retrieve > person from database with: person = service.find(...); and call > person.getJobs() I again get: > > > org.hibern

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, I even tried to do this: org.hibernate.Session session = ((org.hibernate.ejb.HibernateEntityManager) service.getEntityManager()).getSession(); session.lock( persoon.getJobs(), LockMode.NONE); But, it is the same :-(. -- Thx, Milan Milan Milanovic wrote: > > Hi Lukasz, > > grea

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, great, thanks! Yes, I put this new mapping to my web.xml and now my application works. But again when I retrieve person from database with: person = service.find(...); and call person.getJobs() I again get: org.hibernate.LazyInitializationException: could not initialize proxy - no S

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
2008/6/27 Milan Milanovic <[EMAIL PROTECTED]>: > > Hi Lukasz, > > AFAIK I just need to define sessionFactory bean in my applicationContext.xml > to work with my JPA-enabled classes (just like in the Person example) ? How > can I do that ? Sorry!! My big mistake ;-) Right now I discovered that you

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, AFAIK I just need to define sessionFactory bean in my applicationContext.xml to work with my JPA-enabled classes (just like in the Person example) ? How can I do that ? -- Thx, Milan Milan Milanovic wrote: > > Hi Lukasz, > > I tried to define web.xml as you give here, but when I

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
Hi, 2008/6/27 Milan Milanovic <[EMAIL PROTECTED]>: > > Hi Lukasz, > > I tried to define web.xml as you give here, but when I deploy my application > I get this exception: Just look to the doc, link I've sent you, there is such note: Looks up the SessionFactory in Spring's root web application co

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, I tried to define web.xml as you give here, but when I deploy my application I get this exception: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
2008/6/27 Milan Milanovic <[EMAIL PROTECTED]>: > > Hi Lukasz, > > I wrote this in my first post in this thread, I need to read > person.getJobs() when person object is loaded in my action class for this > Struts + AJAX+ Spring + Hibernate example provided in Struts docs, that's > it. Just add that

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, thank you on this example. One question, is this going to work with this Struts 2 + Spring 2 + JPA + AJAX application from Struts 2 docs, i.e., I don't need to change code ? -- Thx, Milan Lukasz Lenart wrote: > >> I see that I can use OpenSessionInViewFilter, just I now need some >

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi Lukasz, I wrote this in my first post in this thread, I need to read person.getJobs() when person object is loaded in my action class for this Struts + AJAX+ Spring + Hibernate example provided in Struts docs, that's it. -- Thx, Milan Lukasz Lenart wrote: > > 2008/6/27 Milan Milanovic <[EM

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
> I see that I can use OpenSessionInViewFilter, just I now need some example > for this kind of application. Example: http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
2008/6/27 Milan Milanovic <[EMAIL PROTECTED]>: > > Hi, > > thank you. Do you know for any example of using this filter for application > like I mentioned ? I'm not quite sure what you need, but this is the common why, how to solve such problem with web applications. Regards -- Lukasz http://www

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
newton.dave wrote: > > --- On Fri, 6/27/08, Milan Milanovic <[EMAIL PROTECTED]> wrote: >>> I now that Hibernate session is closed, I've tried with >>> Hibernate.initialize(person.getJobs()), but it is the same! >> >>... wouldn't the session still be closed? > >>http://www.hibernate.org/hib_doc

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Milan Milanovic
Hi, thank you. Do you know for any example of using this filter for application like I mentioned ? Lukasz Lenart wrote: > > Hi, > > Add OpenSessionInViewFilter [1] filter to your web.xml > > [1] > http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/sup

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Dave Newton
--- On Fri, 6/27/08, Milan Milanovic <[EMAIL PROTECTED]> wrote: > I now that Hibernate session is closed, I've tried with > Hibernate.initialize(person.getJobs()), but it is the same! ... wouldn't the session still be closed? http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Hibernate.html#i

Re: LazyInitializationException with Struts 2 + Spring 2 + JPA + AJAX application

2008-06-27 Thread Lukasz Lenart
Hi, Add OpenSessionInViewFilter [1] filter to your web.xml [1] http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html Regards -- Lukasz http://www.lenart.org.pl/ -