Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTA and web app event listeners

Panagiotis Varlagas
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We wish to perform a transactional table update within the valueUnbound() method of an HttpSessionBindingListener.
The business reason of wanting to do so is that we want to update a user's logon information upon session expiration.
However, in the JTA spec it is specified that web app event listeners may not perform JTA transactions; hence we have a problem doing our transactional update from within valueUnbound().
The spec says that all JTA transactions should be performed from service() threads and the thread invoking valueUnbound is not one. So, we need somehow to make valueUnbound "call" a servlet and
have the servlet's service() (or doGet() for that matter) method do the transactional work.
Getting a dispatcher and asking it to perform a forward is not an attractive solution, since you need to have a request and response object in order to do a forward, so you need to create those and figure out how to set the properties so that the forward works.
Another way of getting a servlet to do the work is getting a URL from the pool, and open a connection to it, where the URL would point to the servlet that would do the transactional work.
However, this seems to be "heavy" performance-wise to me (HTTP traffic involved).
I wonder if you would have some better ideas of doing this.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic