Reputation: 59
I have to use loading bar on selected actions in Struts2, & am using ServletActionContext
, but getting NullPointerException
.
ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
If I remove execAndWait
interceptor from xml configuration file, it works fine.
Some people suggested me to use SessionAware
. Why so ?
Is there any solution ?
Upvotes: 0
Views: 240
Reputation: 1
The ActionContext
is ThreadLocal
and it doesn't have a request object when you run a background thread via execAndWait
interceptor.
If you use SessionAware
, then you should have servletConfig
interceptor on the stack to be able to set the session object to your action before the action is executed.
Solution: if you can get ServletRequestAware
to set a request object to the action and use servletConfig
interceptor prior the execAndWait
interceptor in the stack. If you need to create a custom stack you should keep the order.
Upvotes: 1