hi all,I’m doing a program that making a remote call to read the Domino Address Book information, but it gives me a run-time error.
Here is my code
import main.*;
import network.*;
import utils.*;
import lotus.domino.*;
import java.io.PrintWriter;
public class ReadAddress extends AgentBase //NotesThread
{
//NotesMain method is the entry point for Domino Java Agent
public void NotesMain()
{
try
{
//Create a Session object
Session s = NotesFactory.createSession();
//Session s = this.getSession();
// PrintWriter object use to printoutput
PrintWriter pw = this.getAgentOutput();
//Create a Database object; we will use the name and address book
Database db = s.getDatabase("servername","names.nsf");
//Continue only if the database was properly instantiated
if (db != null)
{
//create a View object using the list of people in the NAB
View vw = db.getView("People");
//Continue only if the View object has been properly instantiated
if (vw != null)
{
//Retrieve the first document in the view
Document doc = vw.getFirstDocument();
//Declare String objects to be used for field values
String fname = null;
String lname = null;
int c = 0;
//Loop through all documents in the view;
while (doc != null)
{
c += 1;
//Retrieve the contents of the FirstName and lastname field as a String
fname = doc.getItemValueString("FirstName");
lname = doc.getItemValueString("LastName");
//display name and counter variable
pw.println("Person #" + c + " : " + fname + " " + lname);
//added here
Document prevdoc = doc;
//Get next document from the view
doc = vw.getNextDocument(doc);
//added here
prevdoc.recycle();
}
//return memory used by View object to the system
vw.recycle();
}
//Return memory used by Database object to the system
db.recycle();
}
//Return memory used by Session object to the system
s.recycle();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
//call function here
import network.*;
import utils.*;
import main.*;
import lotus.domino.*;
import java.io.PrintWriter;
import org.omg.CORBA.ORB;
class callReadAddress{
public static Config config;
public static void main(String args[]){
Config config = new Config();
DiiopAccess diiop = new DiiopAccess();
diiop.setServer(config.getDiiopHost());
diiop.setPort(config.getDiiopPort());
ReadAddress ra = new ReadAddress();
ra.NotesMain();
}
}
Can someone tell what is wrong with my code and what else i need to set?
i do what u said before, but it still gives me the same error, i think i have miss something that need to be set, I’m making a remote called with DIIOP task running at the back, i gope that u may help on this, thank you very much.
Check that first. You can make a local copy of names.nsf from the server and try to loop through all of the names.
By the way, it’s a good practice to put some debugging code into your java. Here’s a quick way to do it:
boolean trace = true;
…
…
if (trace) System.out.println( "Put your debug comments and code here, computing, then printing variables to the console… )
Check the Java console for your output, and you can tell the exact line where you are bombing out.
When you’re done, you can just set trace to false. That will turn all of the output to the console off. There are other more complex ways of debugging, but I’ve found this to be the easiest.
Marcus
P.S. After debugging like I showed you, let me know what line you are having problems with. We can probably find out quickly what the real problem is.
really down’t matter. just make sure that you don’t overwrite your personal names.nsf.
If you pull a replica, call it something like OrgNames.nsf where Org is the name of your organization. This way, when you look at them in your File - Database - Open dialog, you will be able to see the difference quickly!
It will also help you look for names in the Server Directory when you are offline.
Thks for ur reply again, i don’t have any Lotus Notes install locally, beside this, what else i need to change on my coding in order to test the “local call” senario?
xception in thread “main” java.lang.UnsatisfiedLinkError: NCreateSession
at lotus.domino.local.Session.NCreateSession(Native Method)
at lotus.domino.local.Session.createSession(Session.java:94)
at lotus.domino.NotesFactory.createSession(Unknown Source)
at ReadAddress.NotesMain(ReadAddress.java:16)
at callReadAddress.main(callReadAddress.java:39)
I try to disable all the codes in my callReadAddress and only has these 2 lines of codesReadAddress ra = new ReadAddress();
ra.NotesMain();
and it gives me the following errors
at lotus.domino.local.Session.NCreateSession(Native Method)
at lotus.domino.local.Session.createSession(Session.java:94)
at lotus.domino.NotesFactory.createSession(Unknown Source)
at ReadAddress.NotesMain(ReadAddress.java:16)
at callReadAddress.main(callReadAddress.java:39)