This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a problem with my JSF/JPA GlassFish 2 application.
When the user lets a view open for some time and then
saves the data (on my part basically just em.flush())
from time to time no data is saved to the database and
I get a "Closed Connection" error in the log:
I found this Thread which describes my problem
saying that after a short interruption the connection to the Oracle database is not reestablished.
(I would have expected the container to do so without my doing.)
The recommended solution is to put a <uses-external-connection> in my session.xml.
Well, honestly, up til now I didn't know I have to configure a session.xml in my configuration
and I would be happy if someone could explain this and point me to some reference material
where I can find how exactly to do so.
Sounds like your transaction or connection is being timed out. You may be able to configure your timeout in your data source/database/firewall.
Are you using EclipseLink? What version? In general EclipseLink will detect dead connections and reconnect, but this depends on your connection pooling usage.
Are you using a Glassfish connection pool? Have you configured a test connections or timeout setting on it? Otherwise it has no way to detect a dead connection.
You do not need to use a sessions.xml, anything configurable in the old sessions.xml can be configured in the persistence.xml or using a SessionCustomizer.