powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Другие СУБД [игнор отключен] [закрыт для гостей] / как получить доступ к Lotus базе из Java
3 сообщений из 3, страница 1 из 1
как получить доступ к Lotus базе из Java
    #34047850
dmik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
привет. использую стандартный код из хелпа:
import lotus.domino.*;
public class platform implements Runnable
{
Database db;
public static void main(String argv[])
{
Thread nt = new Thread((Runnable)t);
nt.start();
}
public void run()
{
try
{
Session s = NotesFactory.createSession(host, user, pwd);
db = s.getDatabase("myserv1/mydom","test\\calendar.nsf");

.....

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

все это тестируется на IBM RAD 6.0.1 + Apache Tomcat 4.1
и в консоли появляется :

java.lang.NoClassDefFoundError: lotus/domino/local/NotesReferenceQueue
at lotus.domino.NotesThread.checkLoaded(Unknown Source)
at lotus.domino.NotesThread.initThread(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)


пути прописаны в notes.ini
JavaUserClasses=D:\Program Files\lotus\notes\data\domino\java\NCSO.jarr;D:\Program Files\lotus\notes\jvm\lib\ext\Notes.jar
и ServerTasks=http,diiop прописал.
незнаю куда дальше копать, подскажите, пожалуйста
...
Рейтинг: 0 / 0
как получить доступ к Lotus базе из Java
    #34052102
Garrick
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
The following examples demonstrate the minimal code needed for a Java program that uses the Domino classes. The examples instantiate a Session object and print the String output of its getPlatform method (Platform property).

1. This is an application that makes local calls and extends the NotesThread
class:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
import lotus.domino.*;
public class platform1 extends NotesThread
{
  public static void main(String argv[])
    {
        platform1 t = new platform1();
        t.start();
    }
  public void runNotes()
    {
    try
      {
        Session s = NotesFactory.createSession();
        // To bypass Readers fields restrictions
        // Session s = NotesFactory.createSessionWithFullAccess();
        String p = s.getPlatform();
        System.out.println("Platform = " + p);
      }
    catch (Exception e)
      {
        e.printStackTrace();
      }
    }
}

2. This is an application that makes local calls and implements the Runnable interface:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
import lotus.domino.*;
public class platform2 implements Runnable
{
  public static void main(String argv[])
    {
        platform2 t = new platform2();
        NotesThread nt = new NotesThread((Runnable)t);
        nt.start();
    }
  public void run()
    {
    try
      {
        Session s = NotesFactory.createSession();
        String p = s.getPlatform();
        System.out.println("Platform = " + p);
      }
    catch (Exception e)
      {
        e.printStackTrace();
      }
    }
}

3. This is an application that makes local calls and uses the static NotesThread methods:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
import lotus.domino.*;
public class platform3
{
    public static void main(String argv[])
    {
        try
        {
            NotesThread.sinitThread();
            Session s = NotesFactory.createSession();
            String p = s.getPlatform();
            System.out.println("Platform = " + p);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            NotesThread.stermThread();
        }
    }
}


4. This is an agent program where the code is entered through the Domino Designer UI. The UI generates everything in the example except the two lines following // (Your code goes here).

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = 
           session.getAgentContext();
      // (Your code goes here)
      String p = session.getPlatform();
      System.out.println("Platform = " + p);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}


5. This is an agent program where the code is imported into Domino Designer:


Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
import lotus.domino.*;
public class platform4 extends AgentBase

{
    public void NotesMain()
    {
    try
        {
            Session s = getSession();
            String p = s.getPlatform();
            System.out.println("Platform =" + p);
        }
    catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}




6. This is an agent program with print output that can be seen by a browser:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
import lotus.domino.*;
import java.io.PrintWriter;
public class platform5 extends AgentBase
{
    public void NotesMain()
    {
        try
        {
            Session s = getSession();
            String p = s.getPlatform();
            PrintWriter pw = getAgentOutput();
            pw.println("Platform = " + p);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
  

7. This example demonstrates an application that makes remote (IIOP) calls. The example requires the user to enter the name of the host Domino server and optionally a user name and password. If a user name and password are not supplied, the server must allow anonymous access.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
import lotus.domino.*;
public class platform6 implements Runnable
{
  String host=null, user="", pwd="";
  public static void main(String argv[])
    {
      if(argv.length< 1 )
      {
        System.out.println(
           "Need to supply Domino server name");
        return;
      }
      platform6 t = new platform6(argv);
      Thread nt = new Thread((Runnable)t);
      nt.start();
    }
  public platform6(String argv[])
  {
    host = argv[ 0 ];
    if(argv.length >=  2 ) user = argv[ 1 ];
    if(argv.length >=  3 ) pwd = argv[ 2 ];
  }
  public void run()
    {
    try
      {
        Session s = NotesFactory.createSession(
                    host, user, pwd);
        String p = s.getPlatform();
        System.out.println("Platform = " + p);
      }
    catch (Exception e)
      {
        e.printStackTrace();
      }
    }
}

8. To enable SSL in the previous application example, replace:


Код: plaintext
1.
2.
3.
4.
5.
6.
7.
        Session s = NotesFactory.createSession(
                    host, user, pwd);
With:
        String args[] = new String[ 1 ];
        args[ 0 ] = "-ORBEnableSSLSecurity";
        Session s = NotesFactory.createSession(
                    host, args, user, pwd);

TrustedCerts.class (typically in domino\java in the data directory of the server) must be on the classpath. This file is generated by the DIIOP task when it starts.
In order to enable SSL for an applet, you should also enable the attribute "Applet uses CORBA SSL Security" in the "Java Applet Properties" dialog.

9. This example demonstrates an applet that makes Domino calls. AppletBase makes the calls locally if possible, remotely otherwise.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
import lotus.domino.*;
public class foo extends AppletBase
{
  java.awt.TextArea ta;
  public void notesAppletInit()
  {
    setLayout(null);
    setSize( 100 , 100 );
    ta = new java.awt.TextArea();
    ta.setBounds( 0 , 0 , 98 , 98 );
    add(ta);
    ta.setEditable(false);
    setVisible(true);
  }
  public void notesAppletStart()
  {
    Session s = null;
    try
    {
      // Can also do openSession(user, pwd)
      s = this.openSession();
      if (s == null) { //not able to make connection, warn user
        ta.append("Unable to create a session with the server");
        return;
      }
      String p = s.getPlatform();
      ta.append("Platform = " + p);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
    finally
    {
      try {this.closeSession(s);}
      catch(NotesException e) {e.printStackTrace();}
    }
  }
}

10. This example demonstrates an applet that makes Domino calls in code that responds to an AWT event. Because the AWT event handler is a separate thread, you must explicitly initialize and terminate a Domino session if the code is running locally, and must not if the code is running remotely (IIOP).

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
import lotus.domino.*;
import java.awt.*;
import java.awt.event.*;

public class awt extends AppletBase implements ActionListener
{
  private Button b;
  private String text = "";
  Graphics g;
  public java.awt.TextArea ta;
  public Session s;

  public void notesAppletInit()
  {
    g = getGraphics();
    b = new Button("Get user common name");
    add(b);
    ta = new java.awt.TextArea( 15 ,  30 );
    add(ta);
    setVisible(true);
  }

  public void paint(Graphics g)
  {
    b.setLocation( 0 ,  0 );
    ta.setLocation( 200 ,  0 );
  }

  public void notesAppletStart()
  {
    try
    {
      s = this.getSession();
      b.addActionListener(this);
    }
    catch(NotesException e)
    {
      text = e.id + " " + e.text;
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }

  public void actionPerformed(ActionEvent e)
  {
    text = "";
    getTheName();
    ta.append(text + "\n");
  }

  public void getTheName()
  {
    try
    {
      if (isNotesLocal())
      {
        NotesThread.sinitThread();
      }
      text = "User " + s.getCommonUserName();
    }
    catch(NotesException e)
    {
      text = e.id + " " + e.text;
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
    finally
    {
      if (isNotesLocal())
      {
        NotesThread.stermThread();
      }
    }
  }
}




11. This Domino agent gets a token for Single Sign-on and creates a remote (IIOP) session to another server based on the token. The agent runs on the server containing the token.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
import lotus.domino.*;

public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      Session s2 = NotesFactory.createSession("test5.irish.com",
                   session.getSessionToken());
      System.out.println("remote session name = " + s2.getUserName());

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




12. This Domino agent gets a token for Single Sign-on and creates a remote (IIOP) session to a server based on the token. The agent runs a Notes client.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
import lotus.domino.*;

public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      Session s2 = NotesFactory.createSession("test5.irish.com",
                   session.getSessionToken("test5.irish.com"));
      System.out.println("remote session name = " + s2.getUserName());

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


13. This servlet gets a token for Single Sign-on from the LtpaToken cookie through HttpServletRequest and creates a session based on the token.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
import java.lang.*;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import lotus.domino.*;

public class Cookies extends HttpServlet
{
  private void respond(HttpServletResponse response, String entity)
    throws IOException
    {
      response.setContentType("text/plain");
      if (entity == null)
      { response.setContentLength( 0 );}
      else
      {
        response.setContentLength(entity.length() +  1 );
        ServletOutputStream out = response.getOutputStream();
        out.println(entity);
      }
  }

  public void doGet (HttpServletRequest request,
    HttpServletResponse response) 
    throws ServletException, IOException
    {
      String s1 = "";
      Cookie[] cookies = null;
      String sessionToken = null;
      try 
      {
        cookies = request.getCookies();
      }
      catch (Exception e)
      {   
        respond(response,"Exception from request.getCookies(): " +
          e.toString()); 
        return;
      }
      if (cookies == null)
      {
        s1 = "No cookies received";
      }
      else
      {
        for (int i =  0 ; i < cookies.length; i++)
        {
          if (cookies[i].getName().equals("LtpaToken"))
          {
            sessionToken = cookies[i].getValue();
          }
        }
      }
      if (sessionToken != null)
      {
        try
          {
          NotesThread.sinitThread();
          Session session = NotesFactory.createSession(null, sessionToken);
          s1 += "\n" + "Server:           " + session.getServerName();
          s1 += "\n" + "IsOnServer:       " + session.isOnServer();
          s1 += "\n" + "CommonUserName:   " + session.getCommonUserName();
          s1 += "\n" + "UserName:         " + session.getUserName();
          s1 += "\n" + "NotesVersion:     " + session.getNotesVersion();
          s1 += "\n" + "Platform:         " + session.getPlatform();
          NotesThread.stermThread();
          }
          catch (NotesException e)
          {
              s1 += "\n" + e.id + e.text;
              e.printStackTrace();
          }
      }

      respond(response,s1);
  }
}




14. This application snippet creates a session based on a Credentials object

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
obtained from the WebSphere loginHelper.
    org.omg.SecurityLevel2.Credentials credentials =
      loginHelper.request_login("Jane Doe", "", "password",
      new org.omg.SecurityLevel2.CredentialsHolder(),
      new org.omg.Security.OpaqueHolder());
    Session s = NotesFactory.createSession("test5.iris.com", credentials);
    System.out.println("Got Session for " + s.getUserName());


15. This WebSphere Enterprise JavaBeans (ERB) application creates a session based on the current Credentials object in the WebSphere environment.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
import lotus.domino.*;

public class HelloBean extends Object implements SessionBean {

 ... /* See HelloBean.java from Websphere for the complete class code */

  /**
    Returns the greeting. But has been modified to create a remote session to the
    Domino server.
    @return The greeting.
    @exception RemoteException Thrown if the remote method call fails.
  */
  public String getMessage () throws RemoteException
  {
  String result = "hello bean ";

  try {
    Session s = NotesFactory.createSession("test5.iris.com", null);
    result = result + " -- Got Session for " + s.getUserName();
  }
  catch (NotesException ne)
  {
    result = result + "-- " + ne.text;
    result = result + "-- failed to get session for user";
  }

  return (String) result + " -- done";
  }
}
...
Рейтинг: 0 / 0
как получить доступ к Lotus базе из Java
    #34236370
In case WEB Lotus Notes Application - HttpConnection in Java or Ajax. It works fine.
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Другие СУБД [игнор отключен] [закрыт для гостей] / как получить доступ к Lotus базе из Java
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]