Solved

Spring afterCompletion?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

757 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