voyent
Migrated IceFaces webapp to Liferay's Portlet loose Hibernate session  XML
Forum Index -> Portals & Portlets
Author Message
cesarqr

Joined: 01/Dec/2009 00:00:00
Messages: 28
Offline


An ICEFaces project that is working fine over Tomcat 7, when you convert to LIferay Porlet, and you try to run, In the beginning it works fine, it shows the data that becomes from a Hibernate session, but after changing the current row, and listen to rowSelectionListener, it works fine when you go to second row in a ice:datatable, but when you press again the first row, in the datatable, then you get a exception :

Code:
22:37:04,802 ERROR [LazyInitializationException:42] failed to lazily initialize a collection, no session or session was closed
 org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
 	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
  


You can do that with out problem in the Standalone (no portlet) IceFaces.

Why the Hibernate session is close, when you run as porlet under liferay, and keeps open when you run under tomcat?

the app is exactly the same java beans code and xhtml files, the only different are the liferay*.xml and porlet.xml files. and some changes in web.xml.

To migrate in the Eclipse, using Liferay Pluging, I create a new Liferay portlet plugging project, of the type JSF 2.0, than after was working i copy all the src from Icefaces project, and all the need jars into webinf/lib, and xhtml files, then I change (In the porlet.xml) the:
<init-param>
<name>javax.portlet.faces.defaultViewId.view</name>
<value>/xhtml/PropuestasList.xhtml</value>
</init-param>

Do I miss any step?



deryk.sinotte


Joined: 26/Oct/2004 00:00:00
Messages: 1008
Offline


I'm not a Hibernate expert but portlets have slightly different notions of "session" than regular web applications. If I had to guess, I'd say it might be related to that and doesn't really involve ICEfaces.

I recommend Googling for something like:

Code:
hibernate "failed to lazily initialize a collection" portlet


That particular error seems to be pretty common and there are other people out there who have seen the same issue and been able to fix it. One of the top hits I got was:

https://forum.hibernate.org/viewtopic.php?f=1&t=1002633

That forum might have more details for you.

Deryk Sinotte
Team Lead
ICEsoft Technologies, Inc.
cesarqr

Joined: 01/Dec/2009 00:00:00
Messages: 28
Offline


thanks for the reply,

I was trying to implement the Hibernate filter as explain in that post, first I try in the web app not portlet, and works fine, but If try in the portlet, even goes worse than using a PhaseListener, doesn't even shows the first data because the beginTransation() of the filter ghappends after the renderPhase, then you get a error that session is not open.

Is there any way to force Liferay to use hibernateFilter before any Phase, as does in WebApp?
deryk.sinotte


Joined: 26/Oct/2004 00:00:00
Messages: 1008
Offline


Can it be made to work as a PortletFilter rather than a regular web app Filter?

Deryk Sinotte
Team Lead
ICEsoft Technologies, Inc.
cesarqr

Joined: 01/Dec/2009 00:00:00
Messages: 28
Offline


And you make to work as PortletFilter?

I was reading something about that , but wasn't very clear,
Do you Know any good doc or sample?
cesarqr

Joined: 01/Dec/2009 00:00:00
Messages: 28
Offline


And you make to work as PortletFilter?

I was reading something about that , but wasn't very clear,
Do you Know any good doc or sample?
deryk.sinotte


Joined: 26/Oct/2004 00:00:00
Messages: 1008
Offline


I haven't tried to make it work with a portlet filter and we don't have any samples or docs around Hibernate.

Googling for Hibernate with PortletFilter and I found:

https://forum.hibernate.org/viewtopic.php?t=979240

Maybe that will help.

Deryk Sinotte
Team Lead
ICEsoft Technologies, Inc.
 
Forum Index -> Portals & Portlets
Go to:   
Powered by JForum 2.1.7ice © JForum Team