How to get the data form the nsf file or server using java language?

hi,every one

I am the new one in Lotus notes.

How to get the data form the nsf file or server using java language?

I will create the new plug-in for lotus notes.I want to get the data from the nsf file or server using java language. I have seen the notes.jar api, but I can not find the information for that.

Please give me some guide for that, thanks.

tyki

Subject: These articles may help…

“Java access to the Domino Objects, Parts 1 and 2”

Subject: I want to create a eclipse plug-in,then get the data in it.

hi,thanks

I have seen the article.but there are exceptions.

A:

import lotus.domino.Session;

Session s = null;

try {

s = NotesFactory.createSession();

Database d = s.getCurrentDatabase();

DocumentCollection docCollection = d.getAllDocuments();

System.out.println(“--------------doc count:”+docCollection.getCount());

The exception

2011/02/14 17:32:58.359 SEVERE Event loop exception ::class.method=com.ibm.rcp.personality.framework.internal.RCPWorkbenchAdvisor.eventLoopException() ::thread=main ::loggername=com.ibm.rcp.personality.framework.internal

java.lang.NullPointerException

at com.ibm.research.db.DBManager.getData(DBManager.java:20)

at com.ibm.lotuslabs.sidenote.SideNoteViewPart$1.mouseUp(SideNoteViewPart.java:41)

at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)

at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)

at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at com.ibm.rcp.personality.framework.internal.RCPApplication.run(RCPApplication.java:73)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)

at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

2011/02/14 17:32:58.421 SEVERE Unhandled event loop exception ::class.method=unknown ::thread=main ::loggername=org.eclipse.ui

java.lang.NullPointerException

at com.ibm.research.db.DBManager.getData(DBManager.java:20)

at com.ibm.lotuslabs.sidenote.SideNoteViewPart$1.mouseUp(SideNoteViewPart.java:41)

at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)

at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)

at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at com.ibm.rcp.personality.framework.internal.RCPApplication.run(RCPApplication.java:73)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)

at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

2011/02/14 17:35:25.578 SEVERE 启动插件“org.osgi.framework.BundleException: Exception in com.ibm.socnet.client.base.Activator.start() of bundle com.ibm.socnet.client.base.”时遇到问题。 ::class.method=unknown ::thread=Worker-19 ::loggername=org.eclipse.core.runtime

org.osgi.framework.BundleException: Exception in com.ibm.socnet.client.base.Activator.start() of bundle com.ibm.socnet.client.base.

at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1028)

at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:984)

at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:350)

at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:265)

at org.eclipse.core.internal.runtime.InternalPlatform.start(InternalPlatform.java:871)

at org.eclipse.core.internal.plugins.PluginDescriptor.doPluginActivation(PluginDescriptor.java:360)

at org.eclipse.core.internal.plugins.PluginDescriptor.getPlugin(PluginDescriptor.java:340)

at org.eclipse.core.runtime.Platform.getPlugin(Platform.java:755)

at com.ibm.rcp.bizcard.Activator.addPropertyChangeListeners(Activator.java:119)

at com.ibm.rcp.bizcard.Activator.access$0(Activator.java:117)

at com.ibm.rcp.bizcard.Activator$1.run(Activator.java:105)

at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Caused by: java.lang.NoClassDefFoundError: com.ibm.lconn.client.base.common.platform.PolicyHelper

at com.ibm.socnet.client.base.Activator.start(Activator.java:87)

at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:1009)

at java.security.AccessController.doPrivileged(AccessController.java:251)

at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1003)

… 11 more

Caused by: java.lang.ClassNotFoundException: com.ibm.lconn.client.base.common.platform.PolicyHelper

at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:483)

at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)

at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:387)

at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)

at java.lang.ClassLoader.loadClass(ClassLoader.java:609)

… 15 more

B:

Session s = null;

try {

s = NotesFactory.createSession(“D23M0037/23/IBM”);

Database d = s.getCurrentDatabase();

DocumentCollection docCollection = d.getAllDocuments();

System.out.println(“--------------doc count:”+docCollection.getCount());

The exception:

NotesException: Could not get IOR from Domino Server: http://D23M0037/23/IBM/diiop_ior.txt

at lotus.domino.NotesFactory.requestIORPlain(Unknown Source)

at lotus.domino.NotesFactory.requestIORUsingArgs(Unknown Source)

at lotus.domino.NotesFactory.getIOR(Unknown Source)

at lotus.domino.NotesFactory.createSessionUP(Unknown Source)

at lotus.domino.NotesFactory.createSession(Unknown Source)

at lotus.domino.NotesFactory.createSession(Unknown Source)

at com.ibm.research.db.DBManager.getData(DBManager.java:20)

at com.ibm.lotuslabs.sidenote.SideNoteViewPart$1.mouseUp(SideNoteViewPart.java:41)

at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)

at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)

at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at com.ibm.rcp.personality.framework.internal.RCPApplication.run(RCPApplication.java:73)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)

at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

Caused by: NotesException: Invalid IOR null

at lotus.domino.NotesFactory.parseForIOR(Unknown Source)

… 39 more

C:

Session s = null;

try {

s = NotesFactory.createSession(“D23M0037/23/IBM”,“zhyze.nsf”,“1119lijia”);

Database d = s.getCurrentDatabase();

DocumentCollection docCollection = d.getAllDocuments();

System.out.println(“--------------doc count:”+docCollection.getCount());

The exception:

NotesException: Could not get IOR from Domino Server: http://D23M0037/23/IBM/diiop_ior.txt

at lotus.domino.NotesFactory.requestIORPlain(Unknown Source)

at lotus.domino.NotesFactory.requestIORUsingArgs(Unknown Source)

at lotus.domino.NotesFactory.getIOR(Unknown Source)

at lotus.domino.NotesFactory.createSessionUP(Unknown Source)

at lotus.domino.NotesFactory.createSession(Unknown Source)

at com.ibm.research.db.DBManager.getData(DBManager.java:20)

at com.ibm.lotuslabs.sidenote.SideNoteViewPart$1.mouseUp(SideNoteViewPart.java:41)

at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)

at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)

at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at com.ibm.rcp.personality.framework.internal.RCPApplication.run(RCPApplication.java:73)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)

at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

Caused by: NotesException: Invalid IOR null

at lotus.domino.NotesFactory.parseForIOR(Unknown Source)

… 38 more

NotesException: Could not get IOR from Domino Server: http://D23M0037/23/IBM/diiop_ior.txt

at lotus.domino.NotesFactory.requestIORPlain(Unknown Source)

at lotus.domino.NotesFactory.requestIORUsingArgs(Unknown Source)

at lotus.domino.NotesFactory.getIOR(Unknown Source)

at lotus.domino.NotesFactory.createSessionUP(Unknown Source)

at lotus.domino.NotesFactory.createSession(Unknown Source)

at com.ibm.research.db.DBManager.getData(DBManager.java:20)

at com.ibm.lotuslabs.sidenote.SideNoteViewPart$1.mouseUp(SideNoteViewPart.java:41)

at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)

at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)

at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at com.ibm.rcp.personality.framework.internal.RCPApplication.run(RCPApplication.java:73)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

at java.lang.reflect.Method.invoke(Method.java:599)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)

at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

Caused by: NotesException: Invalid IOR null

at lotus.domino.NotesFactory.parseForIOR(Unknown Source)

… 38 more

Subject: Take it slowly…

I’m certainly no expert at Java, but I suggest you start by writing a Java agent inside of a Lotus Notes database to get the basics right before attempting to write plug-ins and servlets. In any case, this technote might help => http://www-01.ibm.com/support/docview.wss?uid=swg21257359

Subject: thanks, I found the reason of exception

I found that when I created the session in the local, I must in the Notes Thread.

The document is very useful.

Thanks again.