On Thu, Aug 26, 2010 at 10:24:41AM +0100, Rohit wrote:
> 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,
have you implemented a setServletRequest method, as described in the FAQ
at
http://struts.apache.org/2.2.1/docs/how-can-we-access-the-httpservletrequest.html
Best regards, Jan
> 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
>
>
>
--
+- Jan T. Kim -------------------------------------------------------+
| email: [email protected] |
| WWW: http://www.cmp.uea.ac.uk/people/jtk |
*-----=< hierarchical systems are for files, not for humans >=-----*
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]