Hi,
I am facing a strange error in Struts2, I am getting a null pointer exception when trying to set attribute into request scope,
Struts Problem Report
Struts has detected an unhandled exception: Messages: File: org/apache/catalina/connector/Request.java Line number: 1,424
Stacktraces
java.lang.NullPointerException
org.apache.catalina.connector.Request.setAttribute(Request.java:1424)
org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:503)
javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284)
com.inrev.bm.action.IRBrandMgmtAction.wrdTwts(IRBrandMgmtAction.java:81)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
My code is given below,
public class IRBrandMgmtAction extends ActionSupport implements SessionAware,ServletRequestAware {
private static final long serialVersionUID = 1L;
private Map session;
private HttpServletRequest request;
private IRWordToTrack wrdtotrack;
private IRBrandMgmtDAO brandMgmtDAO;
private static org.apache.log4j.Logger log = Logger.getLogger(IRBrandMgmtAction.class);
and the method where this is happening,
public String wrdTwts()
{
ArrayList<IRBrandTrackBean> messages = null;
IRDateUtil dtUtil = new IRDateUtil();
String wordId = request.getParameter("wordId");
IRUser user = (IRUser) session.get("user");
IRWordToTrack word = brandMgmtDAO.getWord(Integer.parseInt(wordId));
if(word!=null)
{
messages = brandMgmtDAO.viewMsgForUser(word.getWord().toUpperCase().trim(), null, dtUtil.getTimeZoneOffset(user.getTimeZone()));
}
request.setAttribute("messages",messages);
return "tweets";
}
I am using tomcat 6 server.
Regards, Rohit