2

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
ali ali
  • 89
  • 1
  • 1
  • 5
  • make sure you add the path to the file domingo-1.x.jar to the JavaUserClasses variable in your notes.ini file. the exception simply means that DNotesFactory cannot be found in the classpath. More detailed explanation on this SO post: http://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java – display name Dec 05 '14 at 22:53
  • I added this jar to class path,but it doesn't work – ali ali Dec 05 '14 at 23:02

2 Answers2

2

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:

  1. in directory ...\Lotus\Notes\jvm\lib\ext
  2. in agent's Archive part
  3. 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:

enter image description here

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:

enter image description here


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.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
1

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.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41