Solved

Spring afterCompletion?

Posted on 2014-11-18
3
324 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing to a specific printer tray (HP 806dn printer) 3 83
topping2 challenge 13 82
Java array passed to SQL where clause 23 62
java stored proc example 9 21
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
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.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

910 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

24 Experts available now in Live!

Get 1:1 Help Now