I've a Lotus Script agent which usage Script library which is having Lotus Script classes and those classes are used in the agent.

Sometimes agent unable to include the script library so the line where I create an object of the class gets failed. It throws "Type mismatch on external name" error.




To fix this, I only require to re-save the agent. It doesn't happen frequently but once or twice in a month. How to get rid of this problem ?

A week ago I've asked this question on stackoverflow.com and surprisingly didn't receive any response.



I'm going to get involve ( may be fully ) in deploying customized SharePoint application on our development server.I will sure post my experience with how to do steps.

Meanwhile,I'm really interested to know someone's else experience :)

What could be the possible reason to get this error ,

Unable to store document in xxxxx.nsf (NoteID = 670238) from server xxxxx.nsf (NoteID = 693670): Field length stored in document is incorrect




Does anyone experience this before ? We are getting this error on multiple servers.

From past couple of days I'm working on a prototype project in which pdf form fields should be accessed using Domino Java.

There are couple of tasks involved in this project ,

* Designing user interface in pdf and
* Reading fields data using Java

I have struggle a lot to accomplish these tasks so I thought to blog it for my other fellow LN developers.

Designing user interface in pdf


To design user interface in pdf , You may choose any of these following options,

1- Using iText Java API: IText for Java API provides handful of methods to design user interface in pdf.It's like a old Java AWT methods where you need to calculate coordinates to place your objects.It's not very precise and takes lots of time to design simple interface.Don't go with it if you want to design complex form.

2- Adobe LiveCycle Designer: I've tried with trial version of this tool and found it allows you to design user interface and save it.But,You can't edit it in Adobe reader. For that, You must "Distribute" the form after saving.Distribution option is disabled in trial version and this option remain disabled if you are using stand alone version of this tool ( which I got from net).Adobe LiveCycle designer is integrated with Adobe Acrobat Pro.

3- Adobe InDesign: This can be used to design acro pages but you must use Adobe Acrobat Pro to convert designed page into Acrobat form.You can refer following link to design form in InDesign,

InDesign CS3, In Good Form

4- Adobe Acrobat Pro: I'm using this and it fits perfectly to my need. Here is my sample form designed using Adobe Pro where information can be added and saved.,





Reading fields data using Java


To accomplish this,I've used iText for Java API which seems only way to communicate easily with pdf objects.

Since I'm not using iText to design pdf interface so accessing existing pdf using iText is pretty straight forward.


First, Add following two jars in your "Archive" folder of your agent ,



Here is rest of code,

import lotus.domino.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;

import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.PdfReader;

public class JavaAgent extends AgentBase {

public void NotesMain() {

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

try {
PdfReader reader = new PdfReader("C:\\My Documents\\SampleForm.pdf");
AcroFields form = reader.getAcroFields();
HashMap fields = (HashMap) form.getFields();
String key;

for (Iterator i = fields.keySet().iterator(); i.hasNext(); ) {
key = (String) i.next();
System.out.println(form.getField(key));

}
}
catch (IOException ioe) {
System.err.println(ioe.getMessage());
}

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

Note: If you know the fields name of your pdf form then you don't need for loop to scan entire form.

Here is the output ,





As this project goes, I will write more about it.

I prefer to keep my jars in Archive folder




But some bloggers says better to keep in \jvm\lib\ext\ path.

I'm testing my project on my client later it will work as scheduler.So, I tried to remove my jar from "Archive" folder and placed in following path on my local ,



Restarted my client and recompiled my code, It stop detecting Oracle driver class and suggested following,



Next, I thought to set in Java build path. So, I added my jar in Libraries->Add external jars of project properties. Now, I was able to compile my code but when ran it throws an error "Class is missing".



So, Now I'm again back to my working solution i.e., adding jars in archive folder of an agent.It works perfectly on my client but when I tried making it as a scheduler . It didn't work and server console says,



Should I assume it's because agent is not able to detect "odbc.jar" ?

But some bloggers say "Java.lang.UnsupportedClassVersionError: Bad version number" because when you compile a .java file with one version of JDK and running the .class file with a different version of JVM.

I'm compiling my code on 8.5.1 and server is 8.0.1 ( Linux OS ).

What I would like to know ,

* Where should I keep my jars for client or server based Domino Java apps ?

* If domino client and server are not using same JDK version, How do I make sure my compile code works perfectly on any Domino server?

In my last post ( http://planetlotus.org/735190 ), I've mentioned adding JavaDebugString=-XX:MaxPermSize=256M in my workstation's notes.ini increased the heap size.But,it doesn't seems true when I tested with following piece of code ,

public void NotesMain() {

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

//Get the jvm heap size.
long heapSize = Runtime.getRuntime().totalMemory();
//Print the jvm heap size.
System.out.println("Heap Size = " + heapSize);


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


It says 16777216 in both the cases. Does this setting only works on server's ini file or something wrong with my settings ? So, here are still my unanswered questions,

* How do I increase heap size of Java agents on client or server machine ?

* I assume increasing heap size may affect server performance, So is it possible to increase for just one agent or database ?

I've tried changing HTTPJVMMaxHeapSize but no effect.

I'm in process of aligning my Java agent which mainly does two tasks, One to create Oracle table based on Oracle table configuration domino form and second to push Lotus Notes documents to Oracle.

Unfortunately I haven't used recycle () correctly which leads memory leak and then overflow error. Once I get "Overflow" error, I can't run my Java agent. Every time I try it says same error doesn't matter if I try only with ,

System.out.println("hello world");

I thought if I restart my domino server it will kill hanged threads but I get same error even if I restart my domino server. However, when I restart my client it fixed the problem. So my question are,

* How does Java threads are connected to Notes client?

* How to kill Java threads without restarting Domino server?

Demonstration of recycle method in designer help is fairly simple but how to use efficiently in little complex classes. Here is simple example,

Places where I've used recycle method is commented with "my assumptions".Let me know my mistakes or suggest me better way to design classes.

JavaAgent.java
--------------------------------------------

import lotus.domino.*;

public class JavaAgent extends AgentBase
{


public void NotesMain() {

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
...
Animal cat= new Animal(session);
cat.findDetails(session);

/* my assumptions */
session.recycle();
db.recycle();
/*-------------*/
}
catch(Exception e) {
e.printStackTrace();
}
}
}


Animal Class
-----------------------------------------------

import lotus.domino.*;
import java.sql.*;

public class Animal {

/* find details method */
public String findDetails(Session session) throws Exception
{
try{


Database A= session.getDatabase(db.getServer(), "A");
getCatFromDb("A");
removeCat();
...
/* my assumptions */
conn.close(); //created in constructor
stmt.close(); // created in getCatFromDb
rs.close(); // created in getCatFromDb
A.recycle(); //created in findDetails
db.recycle(); // created in constructor
/*----------*/
}
catch(Exception e)
{

e.printStackTrace();
}
}

/* Start Constructor */
Animal (Session session)throws Exception {
try {
AgentContext agentContext = session.getAgentContext();
db = agentContext.getCurrentDatabase();
conn=...external driver...
...some stuffs from db...
Document doc = db.getProfileDocument("config","");
...some stuffs from doc...

...jdbc connection here...
...
}
catch(Exception e)
{

e.printStackTrace();
}
}
// end Constructor

/* getCatFromDb method */
public void getCatFromDb(Database dbPath){
try{
View v=dbPath.getView("A");
if(v!=null)
{
Document doc= v.getFirstDocument();
while (doc != null)
{
..some stuffs from external db like
creating statement,recordset etc ...

doc = v.getNextDocument(doc);
}
}
}catch(Exception e){e.printStackTrace();}
}
public void removeCat() {

// some stuffs here..

}

}

Any clue about this error ? Please note, I'm not doing anything to handle attachments.



My Java console says , "java.lang.OutOfMemoryError"

I'm recycling session and database once agent is done. Here is some piece of code,



Some more updates , code even doesn't execute very first "system.out.println.." line



Updates:

Adding following in workstation's notes.ini solved the problem,

JavaDebugString=-XX:MaxPermSize=256M

Any consequences in performance if I go with following setting ?

Here is most irritating thing in Domino Java. I'm waiting to finish this saving from last 3-4 minutes.

What should I do ? Kill my Notes and restart or any happy solution ?


Suddenly I'm unable to edit my profile document. I tried creating new but every time ended up with same error. Edit DB Profile agent has @Command([EditProfile];"DBProfile") formula.


Any thoughts ?

Updates : Deleting Cache.NDK file fixed the problem.

To further continue on my problem ( http://planetlotus.org/6a6c9c ),I'm seeking best possible way to build and pass xml of Notes document to third party application.I can't use view directly to generate xml because view contents needs to be updated each time when user use filter conditions.


Now, I'm thinking to convert my Lotus Script agent into a Java one , by thinking "PrintWriter" can provide more size than a Lotus Script print statement .

Can anyone provide some thoughts on this ? or any such experience on R6 servers ?


I've been fighting with Lotus Notes limit issue from past couple of days. I'm building xml file from notes documents and passing them to non domino application.


Initially I chose "variant" data type to store xml file and send using "Print" method. Everything works fine on >R7 servers but failed on R6 servers when document grows more than 1000.

Is there any "variant" data type limit on R6 servers ??

Here is chunk of code using "variant" data type,


Second solution, I've tried using "NotesStream" class. However this one also failed on R6 servers. Though it's mentioned 2GB maximum bytes can be written but still getting failed.

Here is chunk of code using NotesStream class,



Any thoughts ??

preload preload preload