?
Solved

Spring afterCompletion?

Posted on 2014-11-18
3
Medium Priority
?
463 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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.
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

741 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