Try using StrutsStatics class instead. It is what I use.

E.g.

HttpServletResponse response = (HttpServletResponse)
invocation.getInvocationContext().get(StrutsStatics.HTTP_RESPONSE);

HttpServletRequest request = (HttpServletRequest)
context.get(StrutsStatics.HTTP_REQUEST);

Cookie

-----Original Message-----
From: Daniel Stephenson [mailto:dan.stephen...@gmail.com] 
Sent: 30 October 2009 16:35
To: Struts Users Mailing List
Subject: ActionInvocation/ActionContext - NoSuchMethodError

Hello Everyone!

I am trying to upgrade from Struts 2.0.14 to Struts 2.1.8 and have hit a
small snag which I can't seem to resolve through some Google searching.
Following is part of my defined Inteceptor (the intercept method):

...
public String intercept(ActionInvocation invocation)
      throws Exception
   {
      // Get the action context from the invocation so we can access the
      // HttpServletRequest and HttpSession objects.
      final ActionContext context = invocation.getInvocationContext();
      HttpServletRequest request = (HttpServletRequest)
context.get(ServletActionContext.HTTP_REQUEST);
      HttpSession session = request.getSession(true);
      ...
      return invocation.invoke();
   }
...

As soon as I upgraded to version 2.1.8, I started seeing the following
error
when trying to pull the HttpServletRequest object from the context
object:

java.lang.NoSuchMethodError:
com.opensymphony.xwork2.ActionContext.get(Ljava/lang/Object;)Ljava/lang/
Object;
        
com.mcs.therapist.interceptors.SchemaInterceptor.intercept(SchemaInterce
ptor.java:38)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept
(ConversionErrorInterceptor.java:122)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(Pa
rametersInterceptor.java:195)
        
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Me
thodFilterInterceptor.java:87)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercep
t(StaticParametersInterceptor.java:179)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInt
erceptor.java:94)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploa
dInterceptor.java:235)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(Mod
elDrivenInterceptor.java:89)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.interce
pt(ScopedModelDrivenInterceptor.java:130)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(
ProfilingActivationInterceptor.java:104)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(
DebuggingInterceptor.java:267)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(Chaini
ngInterceptor.java:126)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterc
eptor.java:165)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(Prepa
reInterceptor.java:138)
        
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Me
thodFilterInterceptor.java:87)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(Servle
tConfigInterceptor.java:164)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInte
rceptor.java:179)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercep
t(ExceptionMappingInterceptor.java:176)
        
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:237)
        
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java
:52)
        
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:4
88)
        
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher
.java:395)
        
com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.
java:119)
        
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.j
ava:55)
        
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContex
tCleanUp.java:102)
        
com.mcs.therapist.filters.AuditLogFilter.doFilter(AuditLogFilter.java:51
)


I looked at the ActionContext API and it appears that the "get(Object)"
method is still valid, but I'm still missing something.  With this new
version of struts, how do I ultimately get access to the HttpSession?

Thanks for the help.

Daniel Stephenson
dan.stephen...@gmail.com
208.498.2033 - Fax

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to