Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed.
Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed. [message #879932] Fri, 01 June 2012 02:43 Go to next message
Missing name Mising name is currently offline Missing name Mising name
Messages: 12
Registered: July 2011
Junior Member
I have a JSF application that uses Eclipse Persistence Services - 2.1.1.v20100817-r8050, and I sometimes get the following error:

    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.1.v20100817-r8050):    org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed.
    Error Code: 0
    Call: SELECT XXXXX FROM XXXXX
	bind => [/Home/Footer/]
    Query: ReadAllQuery(name="WWW.find" referenceClass=WWW sql="SELECT XXXXX FROM XXXXX")


I have no idea what is causing it. The exception is thrown in the following function on the "return q.getResultList();" line.
    public List<WWW> find(String url) {
        }
        EntityManager em = getEntityManager();
        try {
            Query q = em.createNamedQuery("WWW.find");
            q.setParameter("url", url);
            return q.getResultList();
        } finally {
            em.close();
        }
    }
Re: Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed. [message #880180 is a reply to message #879932] Fri, 01 June 2012 11:08 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1016
Registered: July 2009
Senior Member
Does this error occur after a period of inactivity or under load? A google search for the error suggests that it can be caused by connections being timed out on different servers, so you'll need to look at your connection and datasource settings.

Best Regards,
Chris
Re: Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed. [message #881112 is a reply to message #880180] Sun, 03 June 2012 19:20 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising name
Messages: 12
Registered: July 2011
Junior Member
Our site is never under heavy load and there is usually a few users online at any time.
Below is the properties in our persistence.xml. Any suggestions on what should change?
<properties>
      <property name="javax.persistence.jdbc.password" value="password"/>
      <property name="javax.persistence.jdbc.user" value="user"/>
      <property name="javax.persistence.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.url" value="jdbc:jtds:sqlserver://SERVER:1433/DB"/>
      <property name="eclipselink.ddl-generation" value="none"/>
	  <property name="eclipselink.jdbc.timeout" value="20"/>
	  <property name="eclipselink.jdbc.connections.wait-timeout" value="20"/>
	  <property name="javax.persistence.query.timeout" value="20"/>
	  <property name="eclipselink.allow-zero-id" value="true"/>
	</properties>
Re: Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed. [message #881946 is a reply to message #881112] Tue, 05 June 2012 10:26 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Can you set logging to finest and include the log when the error occurs.

EclipseLink should be retrying dead connections by default.


James : Wiki : Book : Blog : Twitter
Re: Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed. [message #882128 is a reply to message #881946] Tue, 05 June 2012 18:39 Go to previous message
Missing name Mising name is currently offline Missing name Mising name
Messages: 12
Registered: July 2011
Junior Member
I could do that, but I have no idea when this error will occur. So the log would fill up with a lot of junk, and when the error does occur, which is usually over night, the log file would end up being GBs in size.
Previous Topic:class not found javax/validation/ValidatorFactory and ValidationException.errorDecryptingPassword
Next Topic:Proxy could not create EMF from provider org.eclipse.persistence.jpa.osgi.PersistenceProvider
Goto Forum:
  


Current Time: Fri Jul 25 06:43:11 EDT 2014

Powered by FUDForum. Page generated in 0.02721 seconds