Two Laptop Bag*
The moose likes Object Relational Mapping and the fly likes GF2 JPA Closed Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "GF2 JPA Closed Connection" Watch "GF2 JPA Closed Connection" New topic
Author

GF2 JPA Closed Connection

Mark Doerbandt
Greenhorn

Joined: Jun 30, 2011
Posts: 8

Hi, everybody,

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.

Thanks - Mark
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
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.

What is your current persistence.xml?

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Mark Doerbandt
Greenhorn

Joined: Jun 30, 2011
Posts: 8

First of all, thanks for your answer and sorry for getting back so late.
Some christmas days including preparation came suddenly...

Yes, it's a timeout problem, I'm able to reproduce it by open the (edit) view, simply wait and press save.

No, I'm using TopLink, not EclipseLink, since it is GF2 default (and default in my customers blueprint).

I found another warning prior to the Closed Connection in the log today:

Yes, I'm using a GlassFish connection pool:

and my current persistence.xml looks like:


Have you configured a test connections or timeout setting on it?


Well, looking at http://docs.oracle.com/cd/E19879-01/820-4338/abhcy/index.html I don't find a test connections attribute, the timeouts are there.

Do you have any hints for me?

Thanks - Mark
Mark Doerbandt
Greenhorn

Joined: Jun 30, 2011
Posts: 8

anybody? Thanks - Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GF2 JPA Closed Connection
 
Similar Threads
Connection closed
Migrating Toplink/ADF application to MySQL
Does a Connection time out?
EJB3 vs Hibernate vs Toplink vs OpenJPA
How do you get underlying sql exceptions when using Java persistence