Solved

Spring afterCompletion?

Posted on 2014-11-18
3
433 Views
Last Modified: 2014-11-18
I'm attempting to write a Java Spring 4 MVC web application. I would like to know if the afterCompletion interceptor is called after sending the response to the client? Docs say after rendering the view, but I'm not clear if that means sent to the client or just that the view has been prepared to send. Is the request thread alive in this phase? I'm trying to perform request/response logging of transactions and was attempting to complete the response logging in the afterCompletion phase. I'm using a "request" scoped bean to collect bits of transaction information during the request processing and then in the afterCompletion method write this data to logs. However, the process is just stopping in afterCompletion before logging everything. It logs some of it and just stops - no exception.

Thanks.
0
Comment
Question by:kindaprog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 36

Accepted Solution

by:
mccarl earned 500 total points
ID: 40451418
Docs say after rendering the view, but I'm not clear if that means sent to the client or just that the view has been prepared to send
"Rendering" includes the preparation AND sending the content to the client.

Is the request thread alive in this phase?
Yes, at least if you are using normal non-async type processing. I haven't done a lot of the new Async web stuff but I believe that it may work a little differently in that case, since the request thread is returned to the servlet container before the response has been sent. But if you aren't doing async stuff then there shouldn't be a problem.

Can you send any of your code for us to look over?
0
 

Author Closing Comment

by:kindaprog
ID: 40451507
Your response was enough for me to take a second look at my code. After adding some old school debugs and sleep statements I found the issue. I had a line that was causing a null pointer exception. I'm now just not sure why I was not getting this exception in my error log. I'm running the application in iPlanet. Neither the configuration error log (where the application logs) or the admin-server log had the exception or stacktrace. That's a first... I'm fairly new to Java and servlets.

Thank you.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 40451557
Neither the configuration error log (where the application logs) or the admin-server log had the exception or stacktrace
Logging can be a tricky thing. It is also configurable, so any number of things may have "turned off" the logging for the particular class that traps exceptions in the afterCompletion methods. It's just one of those things, unfortunately.

Thank you.
You're welcome!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question