1
votes

I have a Java package that holds utilities, one of which accesses a Notes database. When I first use this class (called from a session scoped bean), which is static and returns a boolean it always seems to throw an exception on accessing the database object. Subsequent calls work.

My code starts off as follows and throws the exception on either the line to access the database or the line that checks if it is open. I saw some folks have posted issues with static classes. Is that the issue or is it something else?

boolean rtn = false;
    try {
    Session session = ExtLibUtil.getCurrentSessionAsSigner();
    if (session.isValid() == false){
        DebugToolbarBean.get().info("Session is not valid");
    } else if (session == null){
        DebugToolbarBean.get().info("session is null");
    } else{
        DebugToolbarBean.get().info("session is good");
    }

    DebugToolbarBean.get().info("Session server is " + session.getServerName());
    DebugToolbarBean.get().info("session" + session.getServerName());
    ConfigBean configBean = (ConfigBean) ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "configBean");
    String nabDbname = (String) configBean.getValue("UserDominoDirectoryPath");
    DebugToolbarBean.get().info("nab db is " + nabDbname);**
    Database nabDb = session.getDatabase(session.getServerName(), nabDbname , false);

    if (nabDb.isOpen()){

In the debug tool bar I get:

18:01:29    Error in validatePhase1java.lang.RuntimeException: Error in checkAddressBook: NotesException: Object has been removed or recycled
18:01:29    error in checkAddressBook:dBar says NotesException: Object has been removed or recycled
18:01:29    nab db is Development\External\Cascade\cascweb3final.nsf
18:01:29    sessionCN=Dev01/O=TSPSDev
18:01:29    Session server is CN=Dev01/O=TSPSDev
18:01:29    session is good
18:01:29    Starting

The rest of the code (that throws the exception is)

} catch (Exception e) {
        rtn = false;
        DebugToolbarBean.get().info("error in checkAddressBook:dBar      " + e.toString() );
        e.printStackTrace();
        throw new RuntimeException( "Error in checkAddressBook: " + e.toString());

    }
4
Must not be the static part... I moved the code into a class in my bean and had the same issue. Failed the first time but worked subsequently.Howard
Can we see the code for checkAddressBook. It may give a pointer to why the error occurs. I had a lot of these where the sessionScoped bean was losing Domino objects in the past.Rob Mason
This is the code for checkAddressBook, I did not include the rest of the code since it never gets there. The exceptions are from my catch statement, I will add to the question above.Howard
It fails even if I pass in the sessionAsSigner into the call to the Java class from my button on the XPage. Very strange, fails the first time and then trying it the second time always works.Howard

4 Answers

1
votes

You don't by any chance recycle your objects in the chekcAddressBook code? That would invalidate the object in all other places where you reference it.

I haven't had these types of problems after having moved to using the OpenNTF Domino API ;-)

0
votes

Sign all design elements using the same developer id. When not all design elements are signed with the same developer id, session will won't be always null and session..getServerName() throws an Exception from my experience. This is only the case when you use the session 'as signer'.

0
votes

If a Bean has an instance member that is a lotus.domino type, it can cause this error when it goes to serialize.

0
votes

Don't really have a firm answer since I hard-coding in the reference to configBean that seemed to invalidate my session object. That worked. Then I put back the original code and that works now too. Been trying over the last few days to get it to fail again but can't...