问题
I'm try debuging the follownig java agent in domino designer
public class JavaAgent extends AgentBase {
public void NotesMain() {
DNotesFactory factory = DNotesFactory.getInstance();
DSession session = factory.getSession();
DDatabase database;
try {
database = session.getDatabase("", "names.nsf");
DView view = database.getView("($Users)");
Iterator entries = view.getAllEntries();
while (entries.hasNext()) {
DViewEntry entry = (DViewEntry) entries.next();
System.out.println(entry.getColumnValues().get(0));
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
but I get the following exception
JavaAgent" java.lang.NoClassDefFoundError: de.bea.domingo.DNotesFactory
回答1:
java.lang.NoClassDefFoundError
is a runtime error. That means, that domingo-1.5.1.jar
is available in Designer during editing and saving Java agent and the code could be compiled.
So, the jar file is not available at runtime.
There are three ways to store jar files for Java agents so that they are available at runtime:
- in directory ...\Lotus\Notes\jvm\lib\ext
- in agent's Archive part
- in Java Library's Archive part
Be aware that jar files in Code/Jars are ignored for Java agents (they can only be used by XPages).
1.
Copy the jar file to directory ...\Lotus\Notes\jvm\lib\ext. Restart the Notes client. Your Java agent will run on Notes client then.
2.
Add the jar file with Import/Archive to Java agent itself:

3.
If you have several agents using the jar file then you should create a Java library with the jar file and include the library to the agents:

From your other questions I can see that you are working with Notes Domino version 9. The project domingo is pretty much out of date and doesn't support all new functionalities. Use OpenNTF Domino API org.openntf.domino instead. A description how to use this API with Java agents you can find here. The places where to store jar files for Java agents are always the same though.
回答2:
If you want to use the domingo classes, you need to add this:
import de.bea.domingo.*;
You might also want to consider using the new OpenNTF Domino API classes instead of the domingo classes. The OpenNTF project is newer and more ambitious, and they are actively improving their code.
来源:https://stackoverflow.com/questions/27325883/javaagent-java-lang-noclassdeffounderror-de-bea-domingo-dnotesfactory