Solved

Spring afterCompletion?

Posted on 2014-11-18
3
333 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
  • 2
3 Comments
 
LVL 35

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 35

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now