Search code examples
javatomcatlotus-domino

Making local calls from Tomcat 7 to Domino 9


I already tried to solve this problem the whole day, but haven't found a solution.

I want to run an web application on Tomcat 7 that does local calls to a Domino 9 Server on the same machine.

My starting point was: http://www-10.lotus.com/ldd/dominowiki.nsf/dx/DIIOP_Usage_and_Troubleshooting_Guide and other articles it links to.

The Server has Ubuntu 14.04 as OS.
I already solved, all the binding errors by changing /etc/default/tomcat7

JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.library.path=/opt/ibm/lotus/notes/latest/linux"

#NOTES_DATA_DIR=/srvmuc202_data
PATH=$PATH:/opt/ibm/lotus/notes/latest/linux:/srvmuc202_data
LD_LIBRARY_PATH=/opt/ibm/lotus/notes/latest/linux
#CLASSPATH=$CLASSPATH:/opt/ibm/lotus/notes/latest/linux/jvm/lib/ext/Notes.jar

The notes.ini is located in the data directory. The only way I found to access it, was adding it to path.

I was not able to change the CLASSPATH properly. That's why it's commented. Tomcat ignores this setting if active.
Edit: I solved it, by adding the Notes.jar to my WAR file.
I use the installed Notes.jar now. It works because I created a symlink to Notes.jar wihtin the Tomcat lib directory /usr/share/tomcat7/lib

Here is my test code:

NotesThread.sinitThread();
Session session = null;
Database db = null;
try {
    session = NotesFactory.createSession();
    if (session != null) {
        log.debug("Session available");
        log.debug("Servername: {}", session.getServerName());
        log.debug("Effective user name: {}", session.getEffectiveUserName());
        log.debug("User name: {}", session.getUserName());
        log.debug("Common user name: {}", session.getCommonUserName());
        log.debug("Notes version: {}", session.getNotesVersion());
        db = session.getDatabase("", "mbur/mburchard.nsf", false);
        if (db != null && db.isOpen()) {
            log.debug("Got database: {}", db.getTitle());
        }
    }
} catch (NotesException e) {
    log.error("", e);
} finally {
    recycle(db);
    recycle(session);
}
NotesThread.stermThread();

Without adding data directory to the path my application works, but has no access to anything. The output is then:

[23606:00002-965273344] Error writing to process file pid.nbf, (other applications may be inappropriately accessing this file)
15:43:45.859 [http-bio-7080-exec-1] DEBUG de.mbur.billing.impl.TestNotes - Session available
15:43:45.859 [http-bio-7080-exec-1] DEBUG de.mbur.billing.impl.TestNotes - Servername: 
15:43:45.859 [http-bio-7080-exec-1] DEBUG de.mbur.billing.impl.TestNotes - Effective user name: 
15:43:45.859 [http-bio-7080-exec-1] DEBUG de.mbur.billing.impl.TestNotes - User name: 
15:43:45.859 [http-bio-7080-exec-1] DEBUG de.mbur.billing.impl.TestNotes - Common user name: 
15:43:45.859 [http-bio-7080-exec-1] DEBUG de.mbur.billing.impl.TestNotes - Notes version: Release 9.0.1FP2HF385 | November 4, 2014

I think, it's because it doesn't know about the notes.ini nor the Domino server id file.

Edit
I added Tomcat to the Domino Servers group and now the err 258 is gone.
Now it behaves the same as without knowing the notes.ini.
No effective username, no access to anything.

With the data directory in the path I get an error message:

15:48:22.650 [http-bio-7080-exec-1] ERROR d.mbur.billing.impl.PersonController - 
java.lang.Exception: Notes initialization failure - err 258
    at lotus.domino.NotesThread.NnotesInitThread(Native Method) ~[Notes.jar:na]
    at lotus.domino.NotesThread.sinitThread(Unknown Source) ~[Notes.jar:na]
    at de.mbur.billing.impl.TestNotes.run(TestNotes.java:18) ~[TestNotes.class:na]
    at de.mbur.billing.impl.PersonController.greeting(PersonController.java:49) ~[PersonController.class:na]

I appreciate any help to get Domino 9 access from Tomcat 7 running the right way. Ideally without adidng Notes.jar to the WAR file and running with full server rights.


Solution

  • After a break I had time to test and solve this problem.

    It was a really small detail. Write rights for the Domino group!

    I'd like to take this answer as chance to write a complete guide.

    Howto access Domino from Tomcat on the same machine

    Tomcat (or any other Program that runs your Java Code) should be in the Domino group, that is normally named notes
    Make sure, that this Domino group has read and write rights on everything in the notes data directory.

    Change the Tomcat configuration (under Ubuntu 14.04 available at /etc/default/tomcat7)

    JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.library.path=/opt/ibm/domino/notes/latest/linux"
    
    PATH=$PATH:/opt/ibm/lotus/notes/latest/linux:/local/notesdata
    LD_LIBRARY_PATH=/opt/ibm/domino/notes/latest/linux
    

    Link to the Notes.jar by switching into the directory /usr/share/tomcat7/lib and creating a symlink.

    sudo ln -s /opt/ibm/domino/notes/latest/linux/jvm/lib/ext/Notes.jar
    

    Deploy your WAR file to Tomcat and be happy :)