Autor Thema: java agent - Selection does not contain a main type  (Gelesen 9078 mal)

Offline shok

  • Frischling
  • *
  • Beiträge: 25
Hallo!
Ich bin gerade dabei einen java Agenten zu programmieren, der Datenbanken kopiert. Hierzu habe ich als Basis einen Code übernommen nur leider wird dieser nicht ausgeführt. Muss ich im Domino Designer noch was einstellen?

import lotus.domino.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

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

// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
DocumentCollection dc = db.search(
"Subject = \"Test appendItemValue\"");
if (dc.getCount() == 1) {
Document doc = dc.getFirstDocument();
Document docCopy = db.createDocument();
docCopy.replaceItemValue("Form", "Main Topic");
docCopy.replaceItemValue("Subject",
"Copy of test appendItemValue");
Item bodyItem = doc.getFirstItem("Body");
docCopy.copyItem(bodyItem, "");
if (docCopy.save())
System.out.println("Document saved");
else
System.out.println("Something went wrong"); }

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

Es kommt folgende Fehlermeldung:
"Selection does not contain a main type"

VG

Offline shok

  • Frischling
  • *
  • Beiträge: 25
Re: java agent - Selection does not contain a main type
« Antwort #1 am: 03.06.11 - 10:37:12 »
habe es falsch gepostet ich glaube das passt mehr zu Entwicklung

Offline m3

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
Re: java agent - Selection does not contain a main type
« Antwort #2 am: 03.06.11 - 10:40:10 »
1) Ja.
2) Was hast Du denn beim Agent eingestellt, auf welche Dokumente er laufen soll?
3) Wird Dein Suchausdruck so nicht funktionieren. Hast Du den schon mal im Volltext-Suchfeld eingegeben?
HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

Offline shok

  • Frischling
  • *
  • Beiträge: 25
Re: java agent - Selection does not contain a main type
« Antwort #3 am: 03.06.11 - 10:44:24 »
der Quelltext ist erstmal nebensächlich... :)
egal wo ich die main Methode versuche einzubauen, wird diese Fehlermeldung ausgewurfen.

Offline m3

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
Re: java agent - Selection does not contain a main type
« Antwort #4 am: 03.06.11 - 10:55:56 »
Code
import lotus.domino.*;

public class JavaAgent extends AgentBase {

	public void NotesMain() {

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

			// (Your code goes here)
			System.out.println("a");
			Database db = agentContext.getCurrentDatabase();
			DocumentCollection dc = db.search(
			"Subject = \"Test appendItemValue\"");
			if (dc.getCount() == 1) {
				Document doc = dc.getFirstDocument();
				Document docCopy = db.createDocument();
				docCopy.replaceItemValue("Form", "Main Topic");
				docCopy.replaceItemValue("Subject",
				"Copy of test appendItemValue");
				Item bodyItem = doc.getFirstItem("Body");
				docCopy.copyItem(bodyItem, "");
				if (docCopy.save())
					System.out.println("Document saved");
				else
					System.out.println("Something went wrong");
			} else {
					System.out.println("Nix gefunden");
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}
Läuft bei mir mit folgenden Settings sauber durch:


HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

Offline m3

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
Re: java agent - Selection does not contain a main type
« Antwort #5 am: 03.06.11 - 10:57:38 »
Und nicht vergessen, wenn Du den Java-Source geändert hast, musst Du nicht nur den speichern, sondern auch "den Agent selbst", sodass oben in der Tab-Leiste keine Sternderln wie in diesem Beispiel sind:
HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

Offline shok

  • Frischling
  • *
  • Beiträge: 25
Re: java agent - Selection does not contain a main type
« Antwort #6 am: 03.06.11 - 11:08:56 »
danke aber, irgendwie klappt das bei mir nicht brauch ich noch extra ecplise?
das sieht folgendermaßen aus...

Offline m3

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
Re: java agent - Selection does not contain a main type
« Antwort #7 am: 03.06.11 - 11:12:13 »
Welche Notes-Version auf welcher Plattform?
Wie startest Du den Client.

BTW: Strg-A, Strg-I, dann wird der Sourceode hübscher eingerückt.
HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

Offline shok

  • Frischling
  • *
  • Beiträge: 25
Re: java agent - Selection does not contain a main type
« Antwort #8 am: 03.06.11 - 11:16:09 »
Lotus Notes 8.5 auf Windows 7

Offline shok

  • Frischling
  • *
  • Beiträge: 25
Re: java agent - Selection does not contain a main type
« Antwort #9 am: 03.06.11 - 12:54:42 »
wie kann ich denn auf die Properties des Agenten zugriefen wie es im Screenshot zusehen ist?

Offline shok

  • Frischling
  • *
  • Beiträge: 25
Re: java agent - Selection does not contain a main type
« Antwort #10 am: 03.06.11 - 15:32:54 »
Kann mir bitte jemand beschreiben wie Java Agenten im Domino Designer ausgeführt werden können?
Brauch ich jetzt eine Main Methode oder brauch ich keine?

Offline m3

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz