1
votes

I am trying to create a REST service using a Servlet that lives inside an NSF. The Servlet runs but I noticed that it handles requests one at a time, so if a request is waiting for a database query to finish, all other requests must wait. I know that requests for Servlets on Tomcat or Glassfish get their own thread but that doesn't seem to be happening on the Domino server. To try and get around this I tried to spawn new threads inside the Servlet but kept getting NotesContext not initialized errors. I searched around and found a project called Threads and Jobs, and intended to use the code there to create a Servlet that spawns new threads and gives the client a requestId and requires them to poll to retrieve the job results, or listen on a port that the server will broadcast on when finished. When I tried to import the project and run it as is, the pages Thread.xsp and Job.xsp rendered but weren't functional. I get the following output in the console:

Thread started

>> Thread running

java.lang.NullPointerException

at com.ibm.domino.xsp.module.nsf.NotesContext.getRunningModule(NotesContext.java:394)

at com.ibm.domino.xsp.module.nsf.NotesContext.checkSignerRightsNonXSP(NotesContext.java:960)

at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.loadClass(ModuleClassLoader.java:379)

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

at org.openntf.samples.thread.ThreadSample$MyThread$1.run(ThreadSample.java:86)

at org.openntf.samples.thread.ThreadSample$MyThread$1.run(ThreadSample.java:1)

at com.ibm.domino.xsp.module.nsf.ThreadSessionExecutor$3.run(ThreadSessionExecutor.java:156)

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

at com.ibm.domino.xsp.module.nsf.ThreadSessionExecutor.run(ThreadSessionExecutor.java:154)

at org.openntf.samples.thread.ThreadSample$MyThread.run(ThreadSample.java:123)

>> Thread running

java.lang.NoClassDefFoundError: lotus/domino/Session

at org.openntf.samples.thread.ThreadSample$MyThread$1.run(ThreadSample.java:86)

at org.openntf.samples.thread.ThreadSample$MyThread$1.run(ThreadSample.java:1)

at com.ibm.domino.xsp.module.nsf.ThreadSessionExecutor$3.run(ThreadSessionExecutor.java:156)

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

at com.ibm.domino.xsp.module.nsf.ThreadSessionExecutor.run(ThreadSessionExecutor.java:154)

at org.openntf.samples.thread.ThreadSample$MyThread.run(ThreadSample.java:123)

>> Thread stopping

Thread left

1

1 Answers

1
votes

You need to design the servlet as OSGi plug-in otherwise it doesn't find the Domino classes. Check this sample for code samples, also have a look at my code for threads and check out Serdar's project on OpenNTF/GitHub

Let us know how it goes.