Announcement Announcement Module
No announcement yet.
Problem with AOP in struts+spring application Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with AOP in struts+spring application

    I am using spring+struts application and want to apply advice on struts action classes.
    As you know there are two ways to integrate spring with struts. Either include ContextLoaderPlugIn
    in struts-config.xml or use spring Action classes.
    I am using Spring Action classes. I have given entry in web.xml as shown below:

    web.xml(either ContextLoaderListener or ContextLoaderServlet)

    org.springframework.web.context.ContextLoaderListe ner

    org.springframework.web.context.ContextLoaderServl et


    This is my action class:

    public class SearchSubmit extends ActionSupport {

    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {

    DynaActionForm searchForm = (DynaActionForm) form;
    String isbn = (String) searchForm.get("isbn");

    //the old fashion way
    //BookService bookService = new BookServiceImpl();
    //ServletContext sc = getServletContext();
    ApplicationContext ctx = getWebApplicationContext();
    //ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicati onContext(sc);
    BookService bookService = (BookService) ctx.getBean("bookService");

    Book book =;


    <aop:aspect ref="LoggingAspect">
    <!-- <aopointcut id="myCutLogging" expression="execution(* ca.nexcel.books.actions.SearchSubmit.execute(..))"/> -->
    <!-- expression="execution(**.*(..))" /> -->
    <aopointcut id="myCutLogging" expression="execution(**.*(..))"/>

    <aop:around pointcut-ref="myCutLogging" method="log" />

    When i am using ContextLoaderListner then when i start the tomcat, i am getting Error Listener start
    and when i use ContextLoaderServlet, tomcat starts successfully but when i navigate in application, it throws
    excetion that WebApplicationContext is not found.Is ContextLoaderListner registered?

    Please help me to solve this issue.

    Thanks in advance.


  • #2
    If your application doesn't start you probably have a configuration issue, figure out what. Crank up the loglevel to DEBUG to see what is happening.

    Next time please use [ code][/code ] tags when posting!