2

When I deploy my application, after a while I get this exception:

    javax.servlet.ServletException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

I'm using a persistence unit, with these settings:

    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="PU" transaction-type="JTA">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>myconnhere</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>NONE</shared-cache-mode>
    <properties>
      <property name="eclipselink.ddl-generation" value="create-tables"/>
     <property name="autoReconnect" value="true"/>
    </properties>
  </persistence-unit>
</persistence>

How can I avoid/fix this problem? Is this a java issue or a MySQL configuration?

I've added <property name="autoReconnect" value="true"/> in the JPA.xml - as I've found on SO. However, this does not fix the issue. I've also removed the connection pool timeout (set to 0) in the GlassFish (3.1.2) administration.

Rob
  • 3,556
  • 2
  • 34
  • 53

1 Answers1

0

It's a driver parameter, and as such you have to modify the URL in the GlassFish connection pool. In the admin UI: Resources -> JDBC -> JDBC Connection Pools -> Your Pool -> Additional Properties.

Another option is to enable Connection Validation in the Advanced tab.

poison
  • 189
  • 3