Hi everyone,
I have been studying for JPA and struggled with a bug which made me very confused and later I have found out that it was Chrome caused the program run incorrectly.
I recently switched from Firefox to Chrome. And when I use glassfish admin console in Chrome, whenever after I deployed the app and try to open
http://<mymachinename>:8080/myapp/runservlet, I found out the
servlet (I don't include code here as it is not specific but generally every servlet dealing with JPA and javadb) will be called TWICE.
Normally if behave correctly, after persisted a entity and auto generate ID, I should get one entity in the database. However, I always get another duplicate in the database. For example, I have a employee named John Smith and I should have a row in Employee table with auto-gen'ed ID 1 and John Smith, but instead somehow, I got ID 1/John Smith and ID 2/John Smith.
At first I thought it was a bug in my code and I tried for a long time to find out but no success. Then I tried same code in IE, the same code behaves correctly no matter how many times I try!
And I tried to run different code and I found it is a general problem not the specific program which I found the problem first with.
Then I found out more:
If I open the app in Chrome at the following address the problem will be gone:
-https://<mymachinename>:8181/myapp/runservlet
-http://localhost:8080/myapp/runservlet
-https://localhost:8181/myapp/runservlet
Do anyone know why app running by Chrome is behaved this way and how to fix it?
Thanks in advance.