0

Here is a little background of my problem:

I'm using Spring MVC 3.1.2.RELEASE. The server is deployed on Amazon AWS. I have a simple controller.

public class MyWebController implements Controller {


    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {

        try {
            String delegateGuid = request.getParameter("delegateGuid");
            String serviceCodesToBeUpdated = request.getParameter("serviceCodesToBeUpdated");
            if (StringUtils.isBlank(delegateGuid) || StringUtils.isBlank(serviceCodesToBeUpdated)) {
                throw new MyException("delegateGuid and/or serviceCodesToBeUpdted cannot be null or empty");
            }

            ...

I have a client script that makes POST request to this endpoint. But sometimes, I hit this MyException that tells me the params are not set. But client logs show that the params are set correctly before sending the requests. The difficult part of debugging this is that it is not reproducible.

Does anyone know what could possibly have caused this issue? I know this might not be the level of detail enough to identify the problem. But if you can suggest any debug logs I could insert into my code, that would be helpful as well. I'm lost in that I don't even know where to start debugging this.

Thanks.

scabbage
  • 1,412
  • 2
  • 15
  • 27
  • Have you checked your web server's access log? If it is `GET` request, the parameters can be found in request URI. For `POST`, you need to dump it yourself, check this [SO post](http://stackoverflow.com/questions/1528628/logging-payload-of-posts-to-tomcat) for an example of tomcat. – ericson Apr 11 '13 at 01:01
  • Thanks. It is a `POST` request. So I will need to follow the instruction for that. – scabbage Apr 11 '13 at 04:14
  • 1
    You're not really using full potential of Spring MVC; you could (should?) bind your paramters using `@RequestParam` annotation instead of extracting them from the request manually. That's a broad subject, though; more info in [the official docs](http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/mvc.html#mvc-ann-requestparam) – kryger Apr 11 '13 at 21:52
  • For a start, I would log the values of the request parameters in the message for MyException: throw new MyException(String.format("delegateGuid: %1 and/or serviceCodesToBeUpdted: %2 cannot be null or empty", delegateGuid, serviceCodesToBeUpdated); – Mark Chorley Apr 11 '13 at 22:31

0 Answers0