Hi,
We are trying to write a java program to change the internet password from shell on a Domino 6.5 server (tried 6.53cf1 and 6.54).
It works on windows but crashes horribly on linux (Redhat ES3 U4):
public class NotesPasswordChange {
public static void main(String[] args) {
if (args.length < 3 || args.length > 3) {
System.out.println("Usage: java NotesPasswordChange <admin password> <username> <password>");
System.exit(1);
}
String adminPassword = args[0];
String userName = args[1];
String password = args[2];
try {
NotesThread.sinitThread();
Session s = NotesFactory.createSession((String)null, (String)null, adminPassword);
Database db = s.getDatabase(null, "names.nsf");
View v = db.getView("($Users)");
DocumentCollection dc = v.getAllDocumentsByKey(userName, true);
if (dc.getCount() == 0) {
System.err.println("User \"" + userName + "\" nicht gefunden!");
System.exit(1);
}
if (dc.getCount() > 1) {
System.err.println("User \"" + userName + "\" nicht eindeutig!");
System.exit(1);
}
Document doc = dc.getFirstDocument();
doc.replaceItemValue("HTTPPassword", s.hashPassword(password));
if (!doc.save(false, false)) {
System.err.println("Änderung des Passworts fehlgeschlagen!");
System.exit(1);
}
System.out.println("Änderung des Passworts erfolgreich.");
System.exit(0);
}
catch (NotesException n) {
n.printStackTrace();
System.exit(1);
}
}
}
[root@asp7 notesdata]# export LD_ASSUME_KERNEL=2.4.19
[root@asp7 notesdata]# export LD_LIBRARY_PATH=/opt/lotus/notes/latest/linux:/opt/lotus/notes/latest/linux/jvm/bin:/opt/lotus/notes/latest/linux/jvm/bin/classic
[root@asp7 notesdata]# /opt/lotus/notes/latest/linux/java -cp /opt/lotus/notes/latest/linux/Notes.jar:. NotesPasswordChange a b c
stackpointer=0xbfffd2c8
JVMXM004: JVM is performing abort shutdown sequence
JVMDG217: Dump Handler is Processing a Signal - Please Wait.
JVMDG303: JVM Requesting Java core file
JVMDG304: Java core file written to /local/notesdata/javacore9769.1112885717.txt
JVMDG215: Dump Handler has Processed Error Signal 6.
Abgebrochen
Thanks for any advice!!!
Rainer
Subject: Java program with notes classes crahes on linux but works on windows
Hi!
Your programm is incomplete you have to recycle the session and end the Domino environment with NotesThread.stermThread() If you do not do this you will have problems with your Domino Server. Best practice to this is add an finally clause to your Try catch block
try{
/*Do what ever you want here */
}
catch(NotesException e){
e.printStackTrace();
}
finally{
if (s!=null){
s.recycle(); // release Domino Backend C++ API objects.
NotesThread.stermThread();
}
I hope this helps you with your problem. If not feel free to ask again
Greetings
Ralf M Petter
P.S. I am not 100% sure if a System.exit(1) prevent the finally clause from running. If that will be true you have to avoid the System.exit in the try catch block.
Subject: RE: Java program with notes classes crahes on linux but works on windows
Thank you for your help.I changed it slightly, but still no go…
import lotus.domino.*;
public class NotesPasswordChange {
public static void main(String[] args) {
if (args.length < 3 || args.length > 3) {
System.out.println("Usage: java NotesPasswordChange <admin password> <username> <password>");
System.exit(1);
}
String adminPassword = args[0];
String userName = args[1];
String password = args[2];
Session s = null;
try {
NotesThread.sinitThread();
s = NotesFactory.createSession((String)null, (String)null, adminPassword);
Database db = s.getDatabase(null, "names.nsf");
View v = db.getView("($Users)");
DocumentCollection dc = v.getAllDocumentsByKey(userName, true);
if (dc.getCount() == 0) {
System.err.println("User \"" + userName + "\" nicht gefunden!");
System.exit(1);
}
if (dc.getCount() > 1) {
System.err.println("User \"" + userName + "\" nicht eindeutig!");
System.exit(1);
}
Document doc = dc.getFirstDocument();
doc.replaceItemValue("HTTPPassword", s.hashPassword(password));
if (!doc.save(false, false)) {
System.err.println("Änderung des Passworts fehlgeschlagen!");
System.exit(1);
}
System.out.println("Änderung des Passworts erfolgreich.");
System.exit(0);
}
catch (NotesException e) {
e.printStackTrace();
System.exit(1);
}
finally {
if (s != null){
try {
s.recycle(); // release Domino Backend C++ API objects.
}
catch (Exception e) {
e.printStackTrace();
}
NotesThread.stermThread();
}
}
}
}
Output is the same:
[root@asp7 notesdata]# /opt/lotus/notes/latest/linux/java -cp /opt/lotus/notes/latest/linux/Notes.jar:. NotesPasswordChange a b c
stackpointer=0xbfffdfc0
JVMXM004: JVM is performing abort shutdown sequence
JVMDG217: Dump Handler is Processing a Signal - Please Wait.
JVMDG303: JVM Requesting Java core file
JVMDG304: Java core file written to /local/notesdata/javacore30257.1112968307.txt
JVMDG215: Dump Handler has Processed Error Signal 6.
Abgebrochen
The core file tells me amongst others:
1HPSIGRECV SIGABRT received in kill at 0xb745cea1 in /lib/i686/libc.so.6. Processing terminated.
Subject: RE: Java program with notes classes crahes on linux but works on windows
Hi!
The programm looks good to me so it should work. I think there is something misconfigured on your Redhat Server. I am not an expert on Domino for Linux.
Greetings
Ralf
P.S. There is a very good german forum for Notes questions www.atnotes.de
Subject: Java program with notes classes crahes on linux but works on windows
Why are you using the Lotus-supplied JVM to run this application? IIRC this is an IBM JVM that has been adapted specifically for usage inside of the Domino server.
Have you tried running this using a regular 1.3.x JVM from Sun?
cheers,
Bram