The Kat's Work - Blog
Main | Blog | Registration | Login
Friday
2017-11-17
5:06 PM
Welcome Guest | RSS
Main » 2011 » August » 10 » RichtextItem Java Class Crashes Notes (Domino) Server
8:11 PM
RichtextItem Java Class Crashes Notes (Domino) Server

This problem and solution were found by my esteemed colleague Andrew "Andy C” Cunliffe.

The problem

In Lotus Notes 8.5 java agents that worked fine in past versions was causing server crashes. Specifically when working with richtextitem class in a java agent. 

The code being effectively this (taken from the help)

import lotus.domino.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

 try {
 Session session = getSession();
 AgentContext agentContext = session.getAgentContext();

 // (Your code goes here)

 DocumentCollection dc = agentContext.getUnprocessedDocuments();
 Document doc = dc.getFirstDocument();
 RichTextItem rti = (RichTextItem)doc.getFirstItem("Body");
 RichTextNavigator rtnav = rti.createNavigator;
 rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH);
 rti.beginInsert(rtnav);
 rti.appendText("Beginning text.");
 rti.addNewLine(1);
 rti.endInsert();
 doc.save(true,true);
 } catch(Exception e) {
 e.printStackTrace();
 }
}


(Quite distressing that the actual example given in the help causes a server crash.)

Investigation

Andy, was able to find that the command beginInsert was causing the crash. This command has been recently changed it now accepts an optional Boolean argument that works as below.
·    true to put the insertion position at the end of the element 
·    false (default) to put the insertion position at the beginning of the element 
Now this is the sticking point, in previous notes versions there was no option and the behaviour of the beginInsert command was to put the insertion point at the end of the element. 

So you can see they have changed the behaviour of the command having the new function be the default and the original function be the alternative function. This was further exasperated by the realisation that the setting of the optional argument to true (i.e. to pick the original function) stops the server crashing.

The Solution

So to conclude the solution to this problem is to change the beginInsert command from



rti.beginInsert(rtnav);

to 

rti.beginInsert(rtnav , true);



I can only think that the new "insertion position at the beginning of the element” is massively resource hungry or not properly garbage collected. Our more high spec servers were able to survive this code. While the server in question could only run the code in "insertion position at the end of the element” mode.

Views: 4855 | Added by: The_Kat | Rating: 5.0/1
Total comments: 0
Name *:
Email *:
Code *:
Login form
Adverts
Search
Calendar
«  August 2011  »
SuMoTuWeThFrSa
 123456
78910111213
14151617181920
21222324252627
28293031
Entries archive
Site friends
  • Create your own site
  • Spree4.com
  • My Blog
  • Statistics

    Total online: 1
    Guests: 1
    Users: 0
    spree4
    Copyright MyCorp © 2017
    Website builderuCoz