Tuesday, November 06, 2007

JPA Connections In Invalid State

Using Glassfish or the Sun Java System Application Server (SJSAS), you will occassionally get the following error:

javax.resource.spi.LocalTransactionException: Connection.close() has already been called. Invalid operation in this state.

It's more prevalent when using JPA with EJB 3.0 in your applications. The solution is surprisingly simple: stop the application server, restart the database (in my case the MySql service), and restart the application server. Simple!