You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Shovon <sh...@yahoo.com> on 2006/05/24 06:51:30 UTC

Lazy Exception in Contrib:Table

Hi,

We have an application in Tapestry 3.x (based on Appfuse 1.8.1), and it
works just fine. We started to upgrade it to Tapestry 4.x (as part of
Appfuse 1.9.1). 

We have been using Lazy Loading in Hibernate in our application from the
beginning. However, we are having a lazy loading exception with one of our
pages. Surprisingly, we did not have that problem in Tapestry 3.x. 

By debugging, I found out that the lazy exception happens in the rewind
phase. However, I do retrieve a fresh copy of the List (which cause the
exception) from a an active hibernate session and save it in the page in the
PageBeginRender method.

We are using the contrib:Table component on this page. If I remove the
contrib:Table  from the page and loop thru the List using forEach component
on the page, we don't get the lazy exception, but can retrieve all the
information. So, it gives me the impression that the Contrib:Table is
somehow saving the object in the http session and trying to reuse a stale
object. Even though the "source" of the Contrib:Table actually contains a
List which gets reassigned to a valid object (connected to an active
hibernate session) in the PageBeginRender method.

I was not able to find a similar issue on the mailing list archive. Any
ideas on how to resolve this?


Thanks ...

Shovon



Here are the a snippets of the related files:



--- .page snippet begins -----
   <page-specification class="com.icqsoft.frisco.webapp.action.Member">
    
    <inject property="memberRoleManager" type="spring"
object="memberRoleManager"/> 

    <property name="row" />
    <property name="saveSubmitter" persist="session"/>
    <property name="selectId" persist="session"/>
    <property name="profiles"/>
    
    </page-specification>

--- .page snippet ends ----



--- .html snippet begins -----

  <table jwcid="table@contrib:Table" 
    row="ognl:row" 
    source="ognl:profiles"
    columns="!Select,!User,!Notes"
    tableSessionStateManager="ognl:new
org.apache.tapestry.contrib.table.model.common.NullTableSessionStateManager()" 
    >

  <span jwcid="SelectColumnValue@Block">
    <input type="radio" jwcid="@Radio" value="ognl:row.profileId"/>
  </span>

  <span jwcid="Candidate_NameColumnValue@Block">
    <span jwcid="@Conditional" condition="ognl:checkInfo(row)">
    Yes 
    </span>
    <span jwcid="@Conditional" condition="ognl:!checkInfo(row)">
     No
   </span>
  </span>

---.html snippet ends ----



----Member.Java snippet begins-----

public abstract class MemberYourCandidates extends BasePage implements
PageRenderListener {

	public abstract Boolean getSaveSubmitter();
	public abstract void setSaveSubmitter(Boolean saveSubmitter);
	public abstract MemberRoleManager getMemberRoleManager();
	public abstract List getProfiles();
	public abstract void setProfiles(List profiles);
	public abstract Long getSelectId();
	public abstract void setSelectId(Long selectId);

	public void pageBeginRender(PageEvent event) {
		
		UserInformation ui = getVisit().getUserInformation();
		MemberRoleManager mgr = getMemberRoleManager();

		//Get an instance of submitter from hibernate session using the primary
key 
		Submitter submitter = mgr.getSubmitter(ui.getMember().getSubmitterId());
		
		//Save a List of profies in the page
		setProfiles(submitter.getProfileList());
	}

	public boolean checkInfo(Profile bcf) {

		if (bcf.getInfosetMgr().getInfosetList().get(0) != null) {
			return true;
		}
		return false;
	}

---Member.Java snippet ends ----











--
View this message in context: http://www.nabble.com/Lazy+Exception+in+Contrib%3ATable-t1673050.html#a4535522
Sent from the Tapestry - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Lazy Exception in Contrib:Table

Posted by Shovon <sh...@yahoo.com>.
We may have the same underlying issue. I think the component saves some
object in the session, and tries to reuse it instead of reading it from the
source each time. 

I will try your recommendations.

Thank you. 

Shovon
--
View this message in context: http://www.nabble.com/Lazy+Exception+in+Contrib%3ATable-t1673050.html#a4567149
Sent from the Tapestry - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Lazy Exception in Contrib:Table

Posted by Jérôme BERNARD <je...@gmail.com>.
I'm not sure I'm talking about the same problem as you have, but I
found a way to solve pagination problems with LazyExceptions
(basically the first page was ok, but not the others -- don't know
why).

What I did was to use a different source for the table: instead of
giving the whole list returned by Hibernate, I wrote my own
IBasicTableModel. It's quite easy to write except for the columns
sorting where I had to use a few tricks to keep the code short. The
nice side effect being that you don't load the whole content at once,
but only one page at a time, so depending on how large is your data,
that can be convenient.

Jérôme.

On 5/25/06, Shovon <sh...@yahoo.com> wrote:
>
> Can anyone shed some light on my original problem? I am upgrading from
> Tapestry 3.x to 4.x. I would look at something like Tapernate once the
> upgrade is done.
>
> Thank you for your help.
>
> Shovon
>
> --
> View this message in context: http://www.nabble.com/Lazy+Exception+in+Contrib%3ATable-t1673050.html#a4554283
> Sent from the Tapestry - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jérôme BERNARD,
Kalixia, SARL.
http://weblog.kalixia.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Lazy Exception in Contrib:Table

Posted by Shovon <sh...@yahoo.com>.
Can anyone shed some light on my original problem? I am upgrading from
Tapestry 3.x to 4.x. I would look at something like Tapernate once the
upgrade is done. 

Thank you for your help.

Shovon

--
View this message in context: http://www.nabble.com/Lazy+Exception+in+Contrib%3ATable-t1673050.html#a4554283
Sent from the Tapestry - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Lazy Exception in Contrib:Table

Posted by James Carman <ja...@carmanconsulting.com>.
There is an example application downloadable via SVN at:

www.carmanconsulting.com/svn/public/tapernate-example/trunk

Tapernate will be moving very soon to the tapestry-javaforge project.  Your
code shouldn't have to change much once we do.

-----Original Message-----
From: Shovon [mailto:shovon@yahoo.com] 
Sent: Wednesday, May 24, 2006 2:19 AM
To: users@tapestry.apache.org
Subject: RE: Lazy Exception in Contrib:Table


Can you please point me to any documentation? I am currenlty using Spring
for
hibernate with the OpenSessionInView filter. Will it be pretty easy to
migrate?

Thanks ...

Shovon
--
View this message in context:
http://www.nabble.com/Lazy+Exception+in+Contrib%3ATable-t1673050.html#a45361
30
Sent from the Tapestry - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Lazy Exception in Contrib:Table

Posted by Shovon <sh...@yahoo.com>.
Can you please point me to any documentation? I am currenlty using Spring for
hibernate with the OpenSessionInView filter. Will it be pretty easy to
migrate?

Thanks ...

Shovon
--
View this message in context: http://www.nabble.com/Lazy+Exception+in+Contrib%3ATable-t1673050.html#a4536130
Sent from the Tapestry - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Lazy Exception in Contrib:Table

Posted by James Carman <ja...@carmanconsulting.com>.
Use tapernate! :-)


-----Original Message-----
From: Shovon [mailto:shovon@yahoo.com] 
Sent: Wednesday, May 24, 2006 12:52 AM
To: users@tapestry.apache.org
Subject: Lazy Exception in Contrib:Table


Hi,

We have an application in Tapestry 3.x (based on Appfuse 1.8.1), and it
works just fine. We started to upgrade it to Tapestry 4.x (as part of
Appfuse 1.9.1). 

We have been using Lazy Loading in Hibernate in our application from the
beginning. However, we are having a lazy loading exception with one of our
pages. Surprisingly, we did not have that problem in Tapestry 3.x. 

By debugging, I found out that the lazy exception happens in the rewind
phase. However, I do retrieve a fresh copy of the List (which cause the
exception) from a an active hibernate session and save it in the page in the
PageBeginRender method.

We are using the contrib:Table component on this page. If I remove the
contrib:Table  from the page and loop thru the List using forEach component
on the page, we don't get the lazy exception, but can retrieve all the
information. So, it gives me the impression that the Contrib:Table is
somehow saving the object in the http session and trying to reuse a stale
object. Even though the "source" of the Contrib:Table actually contains a
List which gets reassigned to a valid object (connected to an active
hibernate session) in the PageBeginRender method.

I was not able to find a similar issue on the mailing list archive. Any
ideas on how to resolve this?


Thanks ...

Shovon



Here are the a snippets of the related files:



--- .page snippet begins -----
   <page-specification class="com.icqsoft.frisco.webapp.action.Member">
    
    <inject property="memberRoleManager" type="spring"
object="memberRoleManager"/> 

    <property name="row" />
    <property name="saveSubmitter" persist="session"/>
    <property name="selectId" persist="session"/>
    <property name="profiles"/>
    
    </page-specification>

--- .page snippet ends ----



--- .html snippet begins -----

  <table jwcid="table@contrib:Table" 
    row="ognl:row" 
    source="ognl:profiles"
    columns="!Select,!User,!Notes"
    tableSessionStateManager="ognl:new
org.apache.tapestry.contrib.table.model.common.NullTableSessionStateManager(
)" 
    >

  <span jwcid="SelectColumnValue@Block">
    <input type="radio" jwcid="@Radio" value="ognl:row.profileId"/>
  </span>

  <span jwcid="Candidate_NameColumnValue@Block">
    <span jwcid="@Conditional" condition="ognl:checkInfo(row)">
    Yes 
    </span>
    <span jwcid="@Conditional" condition="ognl:!checkInfo(row)">
     No
   </span>
  </span>

---.html snippet ends ----



----Member.Java snippet begins-----

public abstract class MemberYourCandidates extends BasePage implements
PageRenderListener {

	public abstract Boolean getSaveSubmitter();
	public abstract void setSaveSubmitter(Boolean saveSubmitter);
	public abstract MemberRoleManager getMemberRoleManager();
	public abstract List getProfiles();
	public abstract void setProfiles(List profiles);
	public abstract Long getSelectId();
	public abstract void setSelectId(Long selectId);

	public void pageBeginRender(PageEvent event) {
		
		UserInformation ui = getVisit().getUserInformation();
		MemberRoleManager mgr = getMemberRoleManager();

		//Get an instance of submitter from hibernate session using
the primary
key 
		Submitter submitter =
mgr.getSubmitter(ui.getMember().getSubmitterId());
		
		//Save a List of profies in the page
		setProfiles(submitter.getProfileList());
	}

	public boolean checkInfo(Profile bcf) {

		if (bcf.getInfosetMgr().getInfosetList().get(0) != null) {
			return true;
		}
		return false;
	}

---Member.Java snippet ends ----











--
View this message in context:
http://www.nabble.com/Lazy+Exception+in+Contrib%3ATable-t1673050.html#a45355
22
Sent from the Tapestry - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org