Error while running the Java agent java.lang.NullPointerException

I have Created a Simple javaagent for the first time as below

try {

      Session session = getSession();

      AgentContext agentContext = session.getAgentContext();



      

      Database db;

      View v1;

      Document doc;

      // (Your code goes here)

      

    

      db = agentContext.getCurrentDatabase();

		v1 = db.getView("vConfig");

		doc=v1.getFirstDocument();

		RichTextItem body = (RichTextItem)doc.getFirstItem("Body");

	      RichTextNavigator rtnav = body.createNavigator();

	      if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {

	        RichTextRange rtrange = body.createRange();

	        rtrange.setBegin(rtnav);

	        

	        System.out.println("hai");

	       // System.out.println(rtrange.getTextParagraph());

	      }



		

    } 

While running the agent i am getting the following error in the Java console . Could anyone can help me . I am using 8.5 version Thanks in advance

java.lang.NullPointerException

at JavaAgent.NotesMain(Unknown Source)

at lotus.domino.AgentBase.runNotes(Unknown Source)

at lotus.domino.NotesThread.run(Unknown Source)

Subject: Error while running the Java agent java.lang.NullPointerException

I suggest you add some error trapping in the code.

Here is an example.

http://www-12.lotus.com/ldd/doc/domino_notes/Rnext/help6_designer.nsf/89d3962efd85426f85256b870069c0aa/3981119508a738ac85256c54004d9d07?OpenDocument

Subject: RE: Error while running the Java agent java.lang.NullPointerException

Thank u

Subject: Add some error checks to the code

You need to narrow it down a bit to find out which pointer is coming up null.

db = agentContext.getCurrentDatabase();

if (db== null) System.out.println(“db is null”);

v1 = db.getView(“vConfig”);

if (v1== null) System.out.println(“v1 is null”);

doc=v1.getFirstDocument();

if (doc-= null) System.out.println(“doc is null”);

RichTextItem body = (RichTextItem)doc.getFirstItem(“Body”);

if (body== null) System.out.println(“body is null”);

RichTextNavigator rtnav = body.createNavigator();

if (rtname== null) System.out.println(“rtnav is null”);

if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {

RichTextRange rtrange = body.createRange();

if (rtrange== null) System.out.println(“rtrange is null”);

rtrange.setBegin(rtnav);

Post your results here if you still can’t figure out what is going on.

-rich

Subject: Also…

Since you mentioned that you are using Notes/Domino 8.5, please be aware that you have posted your question in the Notes/Domino 6 & 7 forum. You would be better off posting it here instead: http://www-10.lotus.com/ldd/nd85forum.nsf. But make the changes I suggested first. The people in the 8.5 forum will want you to do the same level of work narrowing down your own problem before speculating about the cause.

-rich