database doesn't seem to be updated
Hi!
I have a web application that works like this:
1. A client goes to an html page and fills a form with registration data.
2. The form is submitted to a servlet (servlet1) in Application A.
3. The servlet invokes a methd on a session bean with the registration data.
4. The session bean saves the registration data in a database and sends it (by HTTP) to another application (Application B). The message sent has an id to identify the registration.
5. Application B precesses the data.
6. Application B sends the response data to Application A (again, by HTTP) to servlet2.
7. When Application A receives the response and searches the database for a registration with the received id, it doesn't find it!!!!
If I invoke servlet2 manually, the registration is found.
If I do it just after I add the registration to the database it is also found.
But not when Application B invokes servlet2.
All data is saved in the database using CMP entity beans.
Can anyone help me?
Any doubts, please ask!
Nuno Geraldes
[1112 byte] By [
nhpg] at [2007-11-25 10:44:56]

Well... here's what I did to work it out:
After I updated the database, I invoked the findAll() method and it started working fine!
But I still think I shouldn't be forced to do it, so, if anyone knows another way to solve the problem, I'm open to suggestions.
Thanks for the tip, sherry
Nuno Geraldes
nhpg at 2007-7-1 21:39:16 >

> I am wondering if the transaction used by servlet B
> is different and dependending on the database
> transaction properties cannot see the pending
> transaction.
Well, I must say that my code has no reference to any transactions. I use container-managed transactions. Should I change this?
nhpg at 2007-7-1 21:39:16 >

I found out what's happening.
In step 4, when App A sends the message to App B, it sends it to a servlet. The servlet invokes a method on a session bean. The http connection between App A and App B only gets closed after the session bean method returns.
So, as the session bean method in App B sends a message to App A through servlet 2, when servlet 2 executes, App A still hasn't commited the transaction (because it will only commit after the http connection is closed).
I was wondering if I could solve this using threads.
Another question: instead of invoking servlet 2, could the session bean method in App B return the message (it was supposed to send to servlet 2) and put the message in the response so App A could receive it?
nhpg at 2007-7-1 21:39:16 >
