Java.lang.NullPointerException

Hi,

I had created a java agent with two classes, One is main class i.e. class1 and another is class2.

The agent gets successfully compiled on saving, but on running the agent in web, it gives me error at the line where I am setting AgentContext i.e.

AgentContext agentContext1 = session1.getAgentContext();

Plzz help.

import lotus.domino.*;

import java.util.Vector;

public class JavaAgent extends AgentBase {

public void NotesMain() {



	try {

		Session session = getSession();

		String currdocid;

		AgentContext agentContext = session.getAgentContext();

           Agent agent = agentContext.getCurrentAgent();

           Database db = agentContext.getCurrentDatabase();

		RequestDetail obj1 = new RequestDetail();

		String req1 = obj1.getRequestData("docid");

	} catch(Exception e) {

		e.printStackTrace();

	}

}

}

import lotus.domino.*;

public class RequestDetail extends AgentBase

{

String getRequestData(String docid)

 {

 	try

	{

		Session session1 = getSession();

  		AgentContext agentContext1 =  session1.getAgentContext(); // Here error is coming

        Database db1 = agentContext1.getCurrentDatabase();

  		String title = db1.getTitle();

	      System.out.println(title);

		

 	}

 	catch(Exception e) {

		e.printStackTrace();

	}

	return "hello";

}

}

Regards,

Rinkal

Subject: what are you tyring to achive here…

Rinkal,

I am not expert of java agent. but why would you need to declare 2 sessions, 2 agentContext and 2 databases that is all the same thing?

xun

Subject: Problem solved

Hi,

Thanks for responding the post.

The problem has been solved by passing the handle of current database while calling the method, instead of declaring database and session twice in the agent.

Regards,

Rinkal