A Lotus Domino Servlet gives me this error: “Cannot create a session from an agent”

I create a servlet in a Lotus Notes database on a Lotus Domino 9.0 IF5 server. The source code was taken from a tutorial page. Also, the servlet was developed in Domino Designer

This is the most important source code:
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import lotus.domino.*; […] public class TestServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse res) { try { res.setContentType(“text/html”); PrintWriter toBrowser = res.getWriter(); […] try { NotesThread.sinitThread(); Session s = NotesFactory.createSession(); //<== ERROR Database db = s.getDatabase(“”,“names.nsf”); toBrowser.println(db.getTitle()); […] } catch (NotesException n) { System.out.println("Exception ID: " + n.id); System.out.println("Exception description: " + n.text); n.printStackTrace(); } […] } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
When I call the servlet, I get this message on the server console.
13/08/2014 04:31:43 HTTP JVM: Exception ID: 4493 13/08/2014 04:31:43 HTTP JVM: Exception description: Cannot create a session from an agent 13/08/2014 04:31:43 HTTP JVM: NotesException: Cannot create a session from an agent 13/08/2014 04:31:43 HTTP JVM: at lotus.domino.local.Session.checkSecurityManagerExtender(Unknown Source) 13/08/2014 04:31:43 HTTP JVM: at lotus.domino.local.Session.createSession(Unknown Source) 13/08/2014 04:31:43 HTTP JVM: at lotus.domino.NotesFactory.createSession(Unknown Source) […]
If I write the servlet without the Lotus Notes code (Session, Database, Document, etc.) it works fine. I can do everything I want always I do not use the Lotus Domino objects. But if I add that lines, the error occurs.

What would be the problem?

TIA,

EDIT:

This how it looks the servlet on Domino Designer. I wrote it in a Notes DB, no outside as an standalone file

Subject: looks like a bug

Java security has been tightened in various places of late due to new JVM security requirements. Looks like a regression - I put in this spr to track it: JCOR9MXQUU

Thanks!

Subject: It works

I had to write again the servlet as a standalone program, copying the class file on the servlets folder and it worked fine. However, it still does not works as a servlet inside the database.