当我部署我的应用程序时,过了一会儿我得到了这个异常:
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.
我正在使用具有以下设置的持久性单元:
<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>
我怎样才能避免/解决这个问题?这是 java 问题还是 MySQL 配置?
我<property name="autoReconnect" value="true"/>
在 JPA.xml 中添加了 - 正如我在 SO 上找到的那样。但是,这并不能解决问题。我还在 GlassFish (3.1.2) 管理中删除了连接池超时(设置为 0)。