tomcatappfuse

Deploy Appfuse SpringMCV in Tomcat


I want to ask how to deploy application in application server such as tomcat, Im using SpringMVC and run in idea using jetty, when I run in localhost:8080, it works, but when deploy using war in tomcat, the url will be like localhost:8080/app, the login is shown, but when controller calling new page it failed, please help me

the step I reproduce Appfuse is:

  1. Following http://appfuse.org/display/APF/AppFuse+QuickStart, run the generated mvn command
  2. mvn appfuse:full-source
  3. until this step, when I run "mvn jetty:run", it run OK, either I create war using "mvn jetty:run-war" and there is demo.war and I deploy to tomcat still OK
  4. I add some menu and pages, one of them is accountStatement.jsp and accountStatementResult.jsp with their controller. the accountStatement page choose period date and then after click ext button there will be result of accountStatement.
  5. the result of accountStatement.jsp is like: accountStatement You can try it in this link, I already deploy in amazonaws.ec2 server: http://ec2-54-175-88-32.compute-1.amazonaws.com:8080/demo/ username is user/user or admin/admin

  6. I use submit button, and inside the AccountStatementController.java some of the important code is like below:

    public AccountStatementController() {
    setCancelView("redirect:home");
    setSuccessView("/accountStatementResult");
    

    }

    @RequestMapping(method=RequestMethod.POST) public String onSubmit( @RequestParam(value = "periodType", required = false) final String periodType, @RequestParam(value = "datepickerFrom", required = false) final String datepickerFrom, @RequestParam(value = "datepickerUntil", required = false) final String datepickerUntil, @RequestParam(value = "months", required = false) final String months, final RedirectAttributes redirectAttributes, final HttpServletRequest request) throws Exception { String period = datepickerFrom + " - " + datepickerUntil; if (periodType.equals("monthly")) { period = months; }

    redirectAttributes.addFlashAttribute("period", period);
    
    return getSuccessView();
    

    }

  7. When I run from intellij Idea using "mvn jetty:run" it run perfect, after push the submit button, it will redirect to accountStatementResult page.

  8. But when I create demo.war and deploy in tomcat it run error, after accountStatement page and push button, the result is error.

  9. I think the error is in the urlwriter.xml, I ever made application using appfuse 1.9 in my previous office, and now I want to create and sell my own application using appfus. Thank you so much for your help.

I also create the repository of the source on google code, you can ask me the password if you need to see the full code. Thank you


Solution

  • In accountStatement.jsp, change the "action" of your form to be one of the following:

    <form:form commandName="account" method="post" action="accountStatement" id="accountForm">
    

    This produces a relative URL to the controller that you want to submit to. Or you can specify an absolute URL:

    <form:form commandName="account" method="post" action="${ctx}/account/accountStatement" id="accountForm">
    

    I tested and made sure both solutions worked.