JPA tests freeze when receiving HSQL connection from Maven command line

Tests work individually in Eclipse (right-click, run as Junit), but when I run them from the command line with maven, it stops when I try to get a DataSource connection to the HSQL database.

LogicalConnectionImpl [DEBUG] Obtaining JDBC connection

The strangest part for me is that if I limit the tests to 10 (not classes, but separate @Test methods), it will work. But as soon as this 11th test starts, it explodes. The test combinations don't matter, so if I have 30 tests and I choose 11 or more to run, then this will not work. This made me think it was a problem connecting to the DataSource, but so far no luck with the details. I tried adding heap size just for a giggle, but that didn't work.

So, before this freeze, I have several successful JDBC connections and releases.

Here is my applicationContext-HSQL.xml, which is used for both Eclipse and command line versions. I know b / c, I made each of them fail by messing with the class values ​​below.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:flow="http://www.springframework.org/schema/webflow-config"
       xmlns:lang="http://www.springframework.org/schema/lang"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:p="http://www.springframework.org/schema/p"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
          http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
          http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-3.0.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="com.company"/>

    <import resource="classpath*:/application-context-cxf.xml"/>

     <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="persistenceXmlLocation" value="META-INF/persistence.xml"  />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="false" />
                <property name="generateDdl" value="false" />
                <property name="databasePlatform" value="org.hibernate.dialect.HSQLDialect" />
            </bean>
        </property>
    </bean>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
        <property name="url" value="jdbc:hsqldb:mem:test" />
        <property name="username" value="sa" />
        <property name="password" value="" />
    </bean>

    <tx:annotation-driven />
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" >
        <property name="entityManagerFactory" ref="entityManagerFactory"  />
    </bean>
</beans>

Spring 3.2.5, JPA, DBUnit AbstractInMemoryTests.java

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext-hsqldb.xml"})
public class AbstractInMemoryTests {

private static final String FLAT_XML_DATASET = "FlatXmlDataSet.xml";

@Autowired
BasicDataSource bds;

@Before
public void setUp() throws Exception {
    DatabaseOperation.CLEAN_INSERT.execute(getConnection(), getDataSet());
}

@SuppressWarnings("deprecation")
private IDataSet getDataSet() throws Exception {
    InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(FLAT_XML_DATASET);
    IDataSet dataset = new FlatXmlDataSet(inputStream);
    return dataset;
}

private IDatabaseConnection getConnection() throws Exception {
    Connection jdbcConnection = bds.getConnection();
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
    return connection;
}
}

, , ?

,    

+5
3

. maxActive, appContext-hsqldb.xml DataSource

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
    <property name="url" value="jdbc:hsqldb:mem:test" />
    <property name="username" value="sa" />
    <property name="password" value="" />
    ****<property name="maxActive" value="-1"/>****
</bean>

, - .

http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html

+5

- , "kill -3 {process_number}" Unix, ( Unix, Windows/Mac). , , , .

+1

(, 8, maxTotal), . entityManager.close(); db , .

. .

0

All Articles