Hi,
While testing my application for ND7 upgrade I have come across this issue with reading custom data from a notes document.
I am able to run this on ND6 server/client without any problem. When I test this on ND7 server (as an QSA) and in Notes client as action agent, I am getting “ClassNotFound” exception.
I have not tested this on v8 client. If you have v8 client, feel free run this test on v8 as well.
To test, please create a new java agent and past this code.
Call this agent as QSA in one form and call this agent as action agent in client.
I highly appreciate your efforts helping me test this code. This will help me eliminate any issue with my setup before I open a support ticket with Lotus/IBM.
Thanks,
Rupinder
import lotus.domino.*;
import java.util.Collection;
import java.util.ArrayList;
import java.io.IOException;
import java.io.*;
import java.math.BigDecimal;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Class clazz = this.getClass();
ClassLoader cl = clazz.getClassLoader();
System.out.println("Class loader::: " + cl.getClass().getName());
System.out.println("JVM version:::: " + System.getProperty("java.version"));
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
Document doc = db.createDocument();
doc.appendItemValue("Form", "Token");
doc.appendItemValue("Subject", "New document");
doc.appendItemValue("Categories", "Token");
System.out.println("... saving token...");
doc.save();
System.out.println("Ready to save the custom data");
CDHandler.writeData( doc);
doc.save();
System.out.println("Ready to read the custom data");
CDHandler.readData( doc);
} catch(Exception e) {
e.printStackTrace();
}
}
}
class LoanDO implements Serializable {
private String loanNumber ;
private BigDecimal loanAmount;
public LoanDO ( String LN, BigDecimal LAmt) {
Class clazz = this.getClass();
ClassLoader cl = clazz.getClassLoader();
System.out.println("Class loader::: " + cl.getClass().getName());
loanNumber = LN;
loanAmount = LAmt;
}
}
class CDHandler {
// two methods, read and write custom data
public static void writeData ( Document doc ) {
// create 2 LoanDo objects
LoanDO loan1 = new LoanDO("0000011111" , new BigDecimal( 123456.33) );
LoanDO loan2 = new LoanDO("0000022222" , new BigDecimal( 54321.66) );
// store these object to as a collection
Collection loans = new ArrayList();
loans.add(loan1);
loans.add(loan2);
try {
doc.replaceItemValueCustomData( "Custom", loans);
} catch (NotesException ne) {
System.out.println( "Error writing custom data");
ne.printStackTrace();
} catch ( IOException e) {
e.printStackTrace();
}
}
public static void readData (Document doc) {
try {
Object oo = doc.getItemValueCustomData( "Custom");
System.out.println( oo.toString());
} catch (NotesException ne) {
System.out.println( "Error writing custom data");
ne.printStackTrace();
} catch ( ClassNotFoundException ee) {
ee.printStackTrace();
} catch ( IOException e) {
e.printStackTrace();
}
}
}
</Start of the java code>