Fixing an “Object has been removed or recycled” error when searching a view data source

I troubleshot a maddening issue in an XPages application recently, so I’m documenting it in case anyone else comes across it (or has a better solution).

The Problem

In a pretty straightforward application, I have repeat controls with view data sources. The search property of each data source is set to read from a scope variable. (When the user executes a search, the button will build a search string and store it in the scope variable.)

I received numerous reports of an “Object has been removed or recycled” error when executing searches. Sometimes, users would report null pointer errors.

There was no pattern — the same search that triggered the error would work immediately after the error was thrown when the page was refreshed. The same search would work fine the next time.

I could never reproduce the error, but as soon as several testers hit the application, they would see it fairly frequently.

Troubleshooting Steps

I’m well aware of the conflicts that can happen (even across scripts) by recycling Notes/Domino objects, but there’s not a whole lot of code and virtually none of it has to recycle anything! But I took all recycle statements out anyway and the problem did not go away.

I also made sure that every piece of code (even on every computed field just reading from a view column) was wrapped in a try – catch block to see if there’s a trappable error, but no script caught anything.

The Solution

So, I searched for similar reports of the error and found an unrelated issue (related to the pager save state control in a data view), but the solution mentioned in the comments sounded like something worth trying.

Changing the application-level Server page persistence property (in XSP Properties) from “Keep pages in memory” to “Keep pages on disk” solved the problem immediately.

Page Persistence

Is there a better solution? It seems like a pretty significant change to have to make when that may not be the best option for the application overall.

Advertisements

Tags:

8 responses to “Fixing an “Object has been removed or recycled” error when searching a view data source”

  1. Murray says :

    Hi Brad,
    I had the same issue in a different context. I have a repeat with an extension library objectData source in a view scope, which is a Java bean. When I did a partial refresh within the repeat, the repeat var was lost because the bean was somehow lost.
    Setting the persistence setting to Keep Pages on Disk solved the problem.

  2. Lauri Laanti says :

    Did you check the server’s trace log? Specifically, were there any errors like this: “State data not available because no control tree was found in the cache”. I ask because we are currently trying to solve a similar problem with IBM.

    The xsp.persistence.mode setting (or its’ side effects) are not that well documented.

    • Brad Balassaitis says :

      Unfortunately, this was at a client site and I don’t have access to the log.

    • Bryan Schmiedeler says :

      Lauri, that is exactly what I am getting. I have some sessionScope variables and from time to time they end up null and an error is thrown, and then I get the error you mentioned. Would love to find out what this is?

  3. Gary J. Morin says :

    Many thanks for this post! Got a weird issue when users were clicking Cancel to return to the previous page. Changing the persistence did the trick!

  4. Csaba Kiss says :

    Thanks, Brad. You saved my biscuit, again. I received this error inconsistently by trying to upload files to my database. In some cases the file upload worked, in others I received the “Object has been removed or recycled” error. Changing the Persistence worked. I think it would be nice to follow this up with the XPage people, if it’s a feature or a bug.

    • Brad Balassaitis says :

      Glad to hear it was helpful! That is a tough error to track down.

      Depending on how the upload is happening, I think it might be helpful to look at the viewstate setting as well. (Toby Samples blogged about it awhile ago when tracking down an error with a page if REST services.)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: