users@glassfish.java.net

Problem with EclipseLink JPA 1.0 and Glassfish 2.1

From: <glassfish_at_javadesktop.org>
Date: Fri, 30 Apr 2010 08:23:45 PDT

Hi,

  I have been using EclipseLink JPA 1.0 and Glassfish 2.1 for a while now and until recently I had (gladly) no problems. I mainly used EclipseLink for database select/insert/update/delete operations and it worked fine.
  Recently, I had to provide some statistical reports in various formats and I decided to use JasperReports which needs a connection to be passed to the Engine in order to build the report (the connection is needed for the sql query that extracts the data to fill the report) and export it to the desired format.
  I thought that, since I have the Connection available in the EntityManager I could use that connection and pass it to JasperReports. This much is true, however after a couple of times calling that method, glassfish achieved its maximum used connections!
  Glassfish is managing the connections and the EntityManager and so, I believed that I was not required to explicitly close the connection. The fact is that, as soon as I put that statement into the code, glassfish stops achieving the maximum number of used connections.
  I am certain that this cannot be the solution to my problem because, for example, I will have problems if I try to call more than one report in JasperReports or to persist some entities into the database.
  My question is therefore: how can I get hold of the EntityManager's database connection to pass it to JasperReports, build the report with it and letting Glassfish close the connection and the EntityManager without doing it explicitly and without consuming every connection in the connection pool?

Many thanks in advance!

Cheers
[Message sent by forum member 'rviegas']

http://forums.java.net/jive/thread.jspa?messageID=399774