OpenNTF / org.openntf.domino

Open replacement for lotus.domino package in HCL Domino
Apache License 2.0
65 stars 34 forks source link

Error when using two consecutive sessions #122

Closed wolfgang-herder-agi closed 10 years ago

wolfgang-herder-agi commented 10 years ago

I'm trying to use the OpenNTF Domino API in a standalone Java application built against Notes.jar. I've added the org.openntf.domino.jar to the classpath as well as icu4j and com.ibm.commons to the runtime classpath and converted the code. It mostly works fine, but I'm having issues because the programm essentially uses two consecutive Notes sessions. I've boiled down the problem to a simple case:

public static void main(String[] args) {
    NotesThread.sinitThread();
    Session s = Factory.getSession();
    Database db = s.getDatabase(SERVER, DATABASE);
    System.out.println("DB: " + db.getFilePath());
    if(db.isOpen()) {System.out.println("open");}
    NotesThread.stermThread();
    NotesThread.sinitThread();
    Session s2 = Factory.getSession();
    Database db2 = s2.getDatabase(SERVER, DATABASE);
    System.out.println("DB: " + db2.getFilePath());
    if(db2.isOpen()) {System.out.println("open");}
    NotesThread.stermThread();
}

This produces the following console output:

DB: c:\Program Files\IBM\Notes\Data\names.nsf open DB: c:\Program Files\IBM\Notes\Data\names.nsf 2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null _See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace_ 2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null _See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace_ Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getServerName(Unknown Source) at org.openntf.domino.impl.Session.getServerName(Session.java:958) at org.openntf.domino.logging.BaseOpenLogItem.getThisServer(BaseOpenLogItem.java:218) at org.openntf.domino.logging.BaseOpenLogItem.getLogDb(BaseOpenLogItem.java:251) at org.openntf.domino.logging.BaseOpenLogItem.writeToLog(BaseOpenLogItem.java:677) at org.openntf.domino.logging.BaseOpenLogItem.logErrorEx(BaseOpenLogItem.java:583) at org.openntf.domino.logging.BaseOpenLogItem.logError(BaseOpenLogItem.java:661) at org.openntf.domino.logging.OpenLogHandler.publish(OpenLogHandler.java:109) at java.util.logging.Logger.log(Unknown Source) at java.util.logging.Logger.doLog(Unknown Source) at java.util.logging.Logger.log(Unknown Source) at org.openntf.domino.utils.DominoUtils$4.run(DominoUtils.java:279) at java.security.AccessController.doPrivileged(Native Method) at org.openntf.domino.utils.DominoUtils.handleException(DominoUtils.java:273) at org.openntf.domino.impl.Database.resurrect(Database.java:2667) at org.openntf.domino.impl.Database.getDelegate(Database.java:2638) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null _See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace_ Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getDatabase(Unknown Source) at org.openntf.domino.impl.Session.getDatabase(Session.java:698) at org.openntf.domino.logging.BaseOpenLogItem.getLogDb(BaseOpenLogItem.java:251) at org.openntf.domino.logging.BaseOpenLogItem.writeToLog(BaseOpenLogItem.java:677) at org.openntf.domino.logging.BaseOpenLogItem.logErrorEx(BaseOpenLogItem.java:583) at org.openntf.domino.logging.BaseOpenLogItem.logError(BaseOpenLogItem.java:661) at org.openntf.domino.logging.OpenLogHandler.publish(OpenLogHandler.java:109) at java.util.logging.Logger.log(Unknown Source) at java.util.logging.Logger.doLog(Unknown Source) at java.util.logging.Logger.log(Unknown Source) at org.openntf.domino.utils.DominoUtils$4.run(DominoUtils.java:279) at java.security.AccessController.doPrivileged(Native Method) at org.openntf.domino.utils.DominoUtils.handleException(DominoUtils.java:273) at org.openntf.domino.impl.Database.resurrect(Database.java:2667) at org.openntf.domino.impl.Database.getDelegate(Database.java:2638) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getDatabase(Unknown Source) at org.openntf.domino.impl.Database.resurrect(Database.java:2648) at org.openntf.domino.impl.Database.getDelegate(Database.java:2638) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null _See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace_ 2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null _See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace_ Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getDatabase(Unknown Source) at org.openntf.domino.impl.Session.getDatabase(Session.java:698) at org.openntf.domino.logging.BaseOpenLogItem.getLogDb(BaseOpenLogItem.java:251) at org.openntf.domino.logging.BaseOpenLogItem.writeToLog(BaseOpenLogItem.java:677) at org.openntf.domino.logging.BaseOpenLogItem.logErrorEx(BaseOpenLogItem.java:583) at org.openntf.domino.logging.BaseOpenLogItem.logError(BaseOpenLogItem.java:661) at org.openntf.domino.logging.OpenLogHandler.publish(OpenLogHandler.java:109) at java.util.logging.Logger.log(Unknown Source) at java.util.logging.Logger.doLog(Unknown Source) at java.util.logging.Logger.log(Unknown Source) at org.openntf.domino.utils.DominoUtils$4.run(DominoUtils.java:279) at java.security.AccessController.doPrivileged(Native Method) at org.openntf.domino.utils.DominoUtils.handleException(DominoUtils.java:273) at org.openntf.domino.impl.Database.isOpen(Database.java:1908) at test.TestOpenNtf.main(TestOpenNtf.java:29)

Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Database.isOpen(Unknown Source) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

Now, in this simple example, I can easily get rid of the error by removing the sTermThread/sInitThread in the middle. In the large program, not so much.

Is this an error or ist that usage just not supported by the API?

Thanks!

jyyna commented 10 years ago

Standalone usage is not recommended.

the-ntf commented 10 years ago

Sent from the desert of the real.

On Jul 11, 2014, at 7:03, Wolfgang Herder notifications@github.com wrote:

I'm trying to use the OpenNTF Domino API in a standalone Java application built against Notes.jar. I've added the org.openntf.domino.jar to the classpath as well as icu4j and com.ibm.commons to the runtime classpath and converted the code. It mostly works fine, but I'm having issues because the programm essentially uses two consecutive Notes sessions. I've boiled down the problem to a simple case:

public static void main(String[] args) { NotesThread.sinitThread(); Session s = Factory.getSession(); Database db = s.getDatabase(SERVER, DATABASE); System.out.println("DB: " + db.getFilePath()); if(db.isOpen()) {System.out.println("open");} NotesThread.stermThread(); NotesThread.sinitThread(); Session s2 = Factory.getSession(); Database db2 = s2.getDatabase(SERVER, DATABASE); System.out.println("DB: " + db2.getFilePath()); if(db2.isOpen()) {System.out.println("open");} NotesThread.stermThread(); } This produces the following console output:

DB: c:\Program Files\IBM\Notes\Data\names.nsf open DB: c:\Program Files\IBM\Notes\Data\names.nsf 2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace 2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getServerName(Unknown Source) at org.openntf.domino.impl.Session.getServerName(Session.java:958) at org.openntf.domino.logging.BaseOpenLogItem.getThisServer(BaseOpenLogItem.java:218) at org.openntf.domino.logging.BaseOpenLogItem.getLogDb(BaseOpenLogItem.java:251) at org.openntf.domino.logging.BaseOpenLogItem.writeToLog(BaseOpenLogItem.java:677) at org.openntf.domino.logging.BaseOpenLogItem.logErrorEx(BaseOpenLogItem.java:583) at org.openntf.domino.logging.BaseOpenLogItem.logError(BaseOpenLogItem.java:661) at org.openntf.domino.logging.OpenLogHandler.publish(OpenLogHandler.java:109) at java.util.logging.Logger.log(Unknown Source) at java.util.logging.Logger.doLog(Unknown Source) at java.util.logging.Logger.log(Unknown Source) at org.openntf.domino.utils.DominoUtils$4.run(DominoUtils.java:279) at java.security.AccessController.doPrivileged(Native Method) at org.openntf.domino.utils.DominoUtils.handleException(DominoUtils.java:273) at org.openntf.domino.impl.Database.resurrect(Database.java:2667) at org.openntf.domino.impl.Database.getDelegate(Database.java:2638) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getDatabase(Unknown Source) at org.openntf.domino.impl.Session.getDatabase(Session.java:698) at org.openntf.domino.logging.BaseOpenLogItem.getLogDb(BaseOpenLogItem.java:251) at org.openntf.domino.logging.BaseOpenLogItem.writeToLog(BaseOpenLogItem.java:677) at org.openntf.domino.logging.BaseOpenLogItem.logErrorEx(BaseOpenLogItem.java:583) at org.openntf.domino.logging.BaseOpenLogItem.logError(BaseOpenLogItem.java:661) at org.openntf.domino.logging.OpenLogHandler.publish(OpenLogHandler.java:109) at java.util.logging.Logger.log(Unknown Source) at java.util.logging.Logger.doLog(Unknown Source) at java.util.logging.Logger.log(Unknown Source) at org.openntf.domino.utils.DominoUtils$4.run(DominoUtils.java:279) at java.security.AccessController.doPrivileged(Native Method) at org.openntf.domino.utils.DominoUtils.handleException(DominoUtils.java:273) at org.openntf.domino.impl.Database.resurrect(Database.java:2667) at org.openntf.domino.impl.Database.getDelegate(Database.java:2638) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getDatabase(Unknown Source) at org.openntf.domino.impl.Database.resurrect(Database.java:2648) at org.openntf.domino.impl.Database.getDelegate(Database.java:2638) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace 2014-07-11T12:21:48 [WARNING]: lotus.domino.local.NotesBase.CheckObject - null See IBM_TECHNICAL_SUPPORT\org.openntf.log.X.Y.txt for full stack trace Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Session.getDatabase(Unknown Source) at org.openntf.domino.impl.Session.getDatabase(Session.java:698) at org.openntf.domino.logging.BaseOpenLogItem.getLogDb(BaseOpenLogItem.java:251) at org.openntf.domino.logging.BaseOpenLogItem.writeToLog(BaseOpenLogItem.java:677) at org.openntf.domino.logging.BaseOpenLogItem.logErrorEx(BaseOpenLogItem.java:583) at org.openntf.domino.logging.BaseOpenLogItem.logError(BaseOpenLogItem.java:661) at org.openntf.domino.logging.OpenLogHandler.publish(OpenLogHandler.java:109) at java.util.logging.Logger.log(Unknown Source) at java.util.logging.Logger.doLog(Unknown Source) at java.util.logging.Logger.log(Unknown Source) at org.openntf.domino.utils.DominoUtils$4.run(DominoUtils.java:279) at java.security.AccessController.doPrivileged(Native Method) at org.openntf.domino.utils.DominoUtils.handleException(DominoUtils.java:273) at org.openntf.domino.impl.Database.isOpen(Database.java:1908) at test.TestOpenNtf.main(TestOpenNtf.java:29)

Jul 11, 2014 12:21:48 PM org.openntf.domino.utils.DominoUtils$4 run Warnung: null NotesException: Object has been removed or recycled at lotus.domino.local.NotesBase.CheckObject(Unknown Source) at lotus.domino.local.Database.isOpen(Unknown Source) at org.openntf.domino.impl.Database.isOpen(Database.java:1906) at test.TestOpenNtf.main(TestOpenNtf.java:29)

Now, in this simple example, I can easily get rid of the error by removing the sTermThread/sInitThread in the middle. In the large program, not so much.

Is this an error or ist that usage just not supported by the API?

Thanks!

— Reply to this email directly or view it on GitHub.

wolfgang-herder-agi commented 10 years ago

Hi Nathan,

thanks for the reply -- but I don't see anything besides your signature line and the quote of my text?

Let me use this to frame the issue in more general terms:

I've been excited about the possibilites of the OpenNTF Domino API from the start and we have used it in several instances. Now we decided to evaluate the possibility of porting all our existing Domino Java code to it. That's mostly libraries for reading and writing Domino data via a custom API that's a closer fit for the application domain than reading and writing Notes items and documents. As such, they are used in just about any kind of environment, including agents, runjava servlets, XPages beans, standalone client and server applications and OSGi tasklets. Porting only makes sense if I manage to retain the possibility to use the libraries in these environments.

From following the development of the OpenNTF Domino API, I got the impression that it was the goal that it should be possible to use the API anywhere that Java is used to access Domino, and that the apparent focus on using it with XPages was more a product of the main contributors' and early adopters' preferences or interests than some kind of technical limitation. I was somewhat surprised to not find the org.openntf.domino.jar file anywhere in the M4.5 download, which makes it harder to use in some environments, but someone provided a link to a working jar, and that I now use. Is that an indication that the OpenNTF Domino API is moving more towards a XPages-only project?

If on the other hand it's just the case that fewer people test/debug/contribute outside of XPages, I'll gladly put in some time towards trying to understand the inner workings of the API and contributing myself.

Any thoughts?

Thanks,

Wolfgang

the-ntf commented 10 years ago

Sorry. Rough morning here.

I haven't looked at the stack trace yet, but based on the stop and immediate restart of the same thread, I'd start by putting a Thread.sleep(500) in between the stermThread and the sinitThread.

Also, you should probably do a Factory.terminate() before the stermThread.

But generally I have to say that running to independent processes with separate session objects is strange to me. Why are you doing it this way?

Sent from the desert of the real.

On Jul 11, 2014, at 11:40, Wolfgang Herder notifications@github.com wrote:

Hi Nathan,

thanks for the reply -- but I don't see anything besides your signature line and the quote of my text?

Let me use this to frame the issue in more general terms:

I've been excited about the possibilites of the OpenNTF Domino API from the start and we have used it in several instances. Now we decided to evaluate the possibility of porting all our existing Domino Java code to it. That's mostly libraries for reading and writing Domino data via a custom API that's a closer fit for the application domain than reading and writing Notes items and documents. As such, they are used in just about any kind of environment, including agents, runjava servlets, XPages beans, standalone client and server applications and OSGi tasklets. Porting only makes sense if I manage to retain the possibility to use the libraries in these environments.

From following the development of the OpenNTF Domino API, I got the impression that it was the goal that it should be possible to use the API anywhere that Java is used to access Domino, and that the apparent focus on using it with XPages was more a product of the main contributors' and early adopters' preferences or interests than some kind of technical limitation. I was somewhat surprised to not find the org.openntf.domino.jar file anywhere in the M4.5 download, which makes it harder to use in some environments, but someone provided a link to a working jar, and that I now use. Is that an indication that the OpenNTF Domino API is moving more towards a XPages-only project?

If on the other hand it's just the case that fewer people test/debug/contribute outside of XPages, I'll gladly put in some time towards trying to understand the inner workings of the API and contributing myself.

Any thoughts?

Thanks,

Wolfgang — Reply to this email directly or view it on GitHub.

wolfgang-herder-agi commented 10 years ago

Factory.terminate() does the trick, didn't know about that before, thanks!

To answer your question about "why":

Short answer: lazyness on my part and layers of abstraction.

Long answer: The program is a server that implements a protocol (OAI-PMH) to query it for document metadata. The server gets one relevant Notes document after the other, reads the necessary data, discards the document and returns the aggregated data as XML. Later, we wanted to add code that stamped all returned documents, but only if the answer was actually sent, so it couldn't be done while reading the data. The code being fairly complex, with layers of abstraction for different kinds of database systems (with abstract setup and teardown methods), different ways of creating a Session etc., it was easier just to add a new loop at the end, after the request was processed. The laziness comes in that I did not adapt the abstract code to distinguish between getting and recycling a Session and calling s[Init/Term]Thread (there being no such distiction for the other database systems). That would have been next to try, but I'm happy it's not necessary.

From: "Nathan T. Freeman" notifications@github.com To: "OpenNTF/org.openntf.domino" org.openntf.domino@noreply.github.com Cc: Wolfgang Herder wolfgang.herder@agi-imc.de Date: 11.07.2014 17:45 Subject: Re: [org.openntf.domino] Error when using two consecutive sessions (#122)

Sorry. Rough morning here.

I haven't looked at the stack trace yet, but based on the stop and immediate restart of the same thread, I'd start by putting a Thread.sleep(500) in between the stermThread and the sinitThread.

Also, you should probably do a Factory.terminate() before the stermThread.

But generally I have to say that running to independent processes with separate session objects is strange to me. Why are you doing it this way?

Sent from the desert of the real.

On Jul 11, 2014, at 11:40, Wolfgang Herder notifications@github.com wrote:

Hi Nathan,

thanks for the reply -- but I don't see anything besides your signature line and the quote of my text?

Let me use this to frame the issue in more general terms:

I've been excited about the possibilites of the OpenNTF Domino API from the start and we have used it in several instances. Now we decided to evaluate the possibility of porting all our existing Domino Java code to

it. That's mostly libraries for reading and writing Domino data via a custom API that's a closer fit for the application domain than reading and writing Notes items and documents. As such, they are used in just about any kind of environment, including agents, runjava servlets, XPages beans, standalone client and server applications and OSGi tasklets. Porting only makes sense if I manage to retain the possibility to use the libraries in these environments.

From following the development of the OpenNTF Domino API, I got the impression that it was the goal that it should be possible to use the API anywhere that Java is used to access Domino, and that the apparent focus

on using it with XPages was more a product of the main contributors' and

early adopters' preferences or interests than some kind of technical limitation. I was somewhat surprised to not find the org.openntf.domino.jar file anywhere in the M4.5 download, which makes it harder to use in some environments, but someone provided a link to a working jar, and that I now use. Is that an indication that the OpenNTF Domino API is moving more towards a XPages-only project?

If on the other hand it's just the case that fewer people test/debug/contribute outside of XPages, I'll gladly put in some time towards trying to understand the inner workings of the API and contributing myself.

Any thoughts?

Thanks,

Wolfgang — Reply to this email directly or view it on GitHub. — Reply to this email directly or view it on GitHub.