Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)

IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)

Previous Next
Subject: "java/lang/OutOfMemoryError" when running agent around 15 times.
Feedback Type: Problem
Product Area: Domino Server
Technical Area: Application Development
Platform: Windows
Release: 8.5.3
Reproducible: Always


Hi There,

I am writing a Java agent which runs on the Domino server using the code below. I am using the JODConvertor v2.0 Java library "http://www.artofsolving.com/opensource/jodconverter" which leverages openoffice.org to do some .doc to .pdf conversion on a couple of documents with files attached.

However, when I run the agent roughly 15 times I get a "java/lang/OutOfMemoryError". The error trace looks like the below. Just wondered if anyone could shed any light on this issue. assume it is because I am connecting to an OpenOffice.org instance running on port 8100 and somehow this remains open and in memory and then crashes the JVM.

Also please note it is only the JVM that crashes the server continues to function after that, minus the JVM of course.

[1104:003A-186C] 30/04/2012 16:30:03 AMgr: Start executing agent 'CreatePDFOpenOffice-2.2' in 'tb\es\doccontrolyc.nsf'
[1104:003A-186C] 30/04/2012 16:30:05 Agent Manager: Agent error: JVMDUMP006I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" - please wait.
[1104:003A-186C] 30/04/2012 16:30:05 Agent Manager: Agent error: JVMDUMP032I JVM requested Heap dump using 'D:\Lotus\Domino\heapdump.20120430.163005.4356.0001.phd' in response to an event
[1104:003A-186C] 30/04/2012 16:30:07 Agent Manager: Agent error: JVMDUMP010I Heap dump written to D:\Lotus\Domino\heapdump.20120430.163005.4356.0001.phd
[1104:003A-186C] 30/04/2012 16:30:07 Agent Manager: Agent error: JVMDUMP032I JVM requested Snap dump using 'D:\Lotus\Domino\Snap.20120430.163005.4356.0002.trc' in response to an event
[1104:003A-186C] 30/04/2012 16:30:07 Agent Manager: Agent error: JVMDUMP010I Snap dump written to D:\Lotus\Domino\Snap.20120430.163005.4356.0002.trc
[1104:003A-186C] 30/04/2012 16:30:07 Agent Manager: Agent error: JVMDUMP013I Processed dump event "systhrow", detail "java/lang/OutOfMemoryError".
[1104:003A-186C] 30/04/2012 16:30:07 Agent Manager: Agent error: Exception in thread "Thread-39"
[1104:003A-186C] 30/04/2012 16:30:07 Agent Manager: Agent error: java.lang.OutOfMemoryError


import java.io.File;
import java.net.ConnectException;
import java.util.Enumeration;
import java.util.Vector;

import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;


import lotus.domino.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {



Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
View view = db.getView("(Make PDF)");
view.setAutoUpdate(false);


// Here we iterate documents in a view
try
{

System.out.println("Starting Create PDF with OpenOffice - Agent");

boolean saveFlag = false;
String PDFLocationAndFileName = "";
String DOCLocationAndFileName = "";
Document doc = view.getFirstDocument();
Document docTmp = null;

File inputFile = null;
File outputFile = null;

//Set Date Variable
DateTime dt = session.createDateTime("Today");


//If there actually is a doc start up the office manager instance

OpenOfficeDocumentConverter converter = null;
OpenOfficeConnection connection = null;

if(null != doc){

// connect to an OpenOffice.org instance running on port 8100
connection = new SocketOpenOfficeConnection(8100);

try {
connection.connect();

} catch (ConnectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// convert
converter = new OpenOfficeDocumentConverter(connection);


}


//Start looping the docs
while (null != doc)
{

//Get Current DOC file from the Rich Text field
RichTextItem body = (RichTextItem)doc.getFirstItem("DC_Body");

Vector v = body.getEmbeddedObjects();
Enumeration e = v.elements();

String DocFilename = null;
while (e.hasMoreElements()) {

EmbeddedObject eo = (EmbeddedObject)e.nextElement();
if (eo.getType() == EmbeddedObject.EMBED_ATTACHMENT)
{
DocFilename = eo.getName();
eo.extractFile("e:\\PDFConvert\\" + eo.getSource());
//eo.remove();
saveFlag = true;
}

}/* End While */

if (saveFlag) {

/** Get Filenames and paths **/
//Doc Filename Variable
DOCLocationAndFileName = "e:\\PDFConvert\\" + DocFilename ;
//PDF Filename Variable
DocFilename = DocFilename.substring(0, DocFilename.lastIndexOf('.'));
PDFLocationAndFileName = "e:\\PDFConvert\\" + DocFilename + ".pdf";


//System.out.println(DOCLocationAndFileName);

/** Lets Create the PDF Now **/


inputFile = new File(DOCLocationAndFileName );
outputFile = new File(PDFLocationAndFileName);

System.out.println("Start OpenOffice PDF creator Code");
converter.convert(inputFile, outputFile);
System.out.println("Finished OpenOffice PDF creator Code");


try
{

/** Attach PDF to the Document **/

Item PDFFieldRichText = doc.getFirstItem("DC_Body_PDF");
((RichTextItem) PDFFieldRichText).embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, PDFLocationAndFileName , PDFLocationAndFileName );
Integer intObj = new Integer(6);

//doc.replaceItemValue("DC_Stage", intObj);
doc.replaceItemValue("DC_PDFCreated","True");
doc.replaceItemValue("DC_DocumentStatus","Current - " + dt);
doc.save(true, true);


}
catch (NotesException n)
{
n.printStackTrace();
}


System.out.println("At the end of the loop");


}

docTmp = view.getNextDocument(doc);
doc = docTmp;

}


//If no more docs kill the office manager
if (doc == null){

System.out.println("Stopping");


// close the connection
connection.disconnect();

connection = null;
converter = null;


}


inputFile = null;
outputFile = null;
DOCLocationAndFileName = null;
PDFLocationAndFileName =null;

if (null != doc) doc.recycle();
if (null != docTmp) docTmp.recycle();

}
catch (NotesException e)
{
e.printStackTrace();
}
finally
{
try
{


view.recycle();
db.recycle();


}
catch (NotesException n)
{
//Don't care
}
}


agentContext.recycle();
session.recycle();


System.out.println("End");

/**Find out how many threads are running **/
//System.out.println("Dump the current threadgroup:\n");
//dumptg(null);


// (Your code goes here)

} catch(Exception e) {
e.printStackTrace();
}
}


}


Feedback number WEBB8TVCX9 created by Aden Roper on 05/01/2012

Status: Open
Comments:

"java/lang/OutOfMemoryError" when r... (Aden Roper 1.May.12)
. . Garbage collection/Recycling issues... (Kenneth Axi 1.May.12)
. . . . Updated Code (Aden Roper 1.May.12)
. . . . . . Dont recycle object that You have c... (Kenneth Axi 2.May.12)
. . . . . . . . To add to your comments. (Simon O'Doherty... 2.May.12)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support


 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite