title: H2 in-memory test DB closed, despite 'DB_CLOSE_ON_EXIT=FALSE'
body: <p>I have some short unit tests that fail with the exception:</p>
  
  <pre><code>javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement
  ::
  Caused by: org.hibernate.exception.GenericJDBCException: could not prepare statement
  ::
  Caused by: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-197]
  </code></pre>
  
  <p>The source is my Spring Data AuditProvider, specifically this line:</p>
  
  <pre><code>user = entityManager.createNamedQuery("findUserByUsernameAndTenant", User.class)
          .setParameter("tenant", TenantService.DEFAULT_TENANT_ID)
          .setParameter("username", UserService.USER_SYSTEM).getSingleResult();
  </code></pre>
  
  <p>The Error happens <strong>only</strong> when executing the whole test suite, not when running this test class only.</p>
  
  <p>Here the TestRunner I'm using etc:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  @Transactional
  @Rollback
  public class MyTest {
  </code></pre>
  
  <p>That's my datasource URL:</p>
  
  <pre><code>spring.datasource.url: 'jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE'
  </code></pre>
  
  <p>So it seems "DB_CLOSE_ON_EXIT" doesn't solve the problem, any idea what's happening here?</p>
  
  <p>UPDATE:</p>
  
  <p>I just realized, that this happens only when running the tests in Eclipse, but they run through in the command line. While I do get the occasional:</p>
  
  <pre><code>o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL)
  </code></pre>
  
  <p>but I don't get the PersistenceException and stacktrace.</p>