Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:26:12+00:00 2026-05-27T19:26:12+00:00

I am developping a web application using Spring (3.1.x), JSF 2, JPA 2 (Hibernate

  • 0

I am developping a web application using Spring (3.1.x), JSF 2, JPA 2 (Hibernate Provider) for tomcat 6.x. I want to test my DAO classes.
My application database is under MySql.
For the test i want to use HSQLDB in memory.

I made some scripts who create the schema and the tables under hsqldb, I call them with maven sql plugin.

pom.xml:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sql-maven-plugin</artifactId>
                <version>1.5</version>

                <dependencies>
          <!-- specify the dependent jdbc driver here -->
                    <dependency>
                        <groupId>hsqldb</groupId>
                        <artifactId>hsqldb</artifactId>
                        <version>1.8.0.10</version>
                    </dependency>
                </dependencies>

        <!-- common configuration shared by all executions -->
                <configuration>
                    <driver>org.hsqldb.jdbcDriver</driver>
                    <url>jdbc:hsqldb:mem:testOpen</url>
                    <username>sa</username>
                    <password></password>
          <!-- You can comment out username/password configurations and
               have maven to look them up in your settings.xml using ${settingsKey}
          -->
                    <settingsKey>sensibleKey</settingsKey>
          <!--all executions are ignored if -Dmaven.test.skip=true-->
                    <skip>${maven.test.skip}</skip>
                </configuration>

                <executions>
                    <execution>
                        <id>drop-db-before-test-if-any</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
              <!-- need another database to drop the targeted one -->
                            <url>jdbc:hsqldb:mem:testOpen</url>
                            <autocommit>true</autocommit>
                            <sqlCommand>DROP SCHEMA testOpen CASCADE</sqlCommand>
              <!-- ignore error when database is not avaiable -->
                            <onError>continue</onError>
                        </configuration>
                    </execution>

                    <execution>
                        <id>create-db</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <url>jdbc:hsqldb:mem:testOpen</url>
              <!-- no transaction -->
                            <autocommit>true</autocommit>
                            <sqlCommand>CREATE SCHEMA testOpen AUTHORIZATION DBA</sqlCommand>
                        </configuration>
                    </execution>

                    <execution>
                        <id>create-tables</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <url>jdbc:hsqldb:mem:testOpen</url>
                            <autocommit>true</autocommit>
                            <srcFiles>
                                <srcFile>conf/script_sql/hsqldb/create_tables.sql</srcFile>
                            </srcFiles>
                        </configuration>
                    </execution>

                    <execution>
                        <id>check-data</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <url>jdbc:hsqldb:mem:testOpen</url>
                            <autocommit>true</autocommit>
                            <printResultSet>true</printResultSet>
                             <sqlCommand>SELECT * FROM INFORMATION_SCHEMA.SYSTEM_COLUMNS WHERE TABLE_NAME NOT LIKE 'SYSTEM_%'</sqlCommand>
                        </configuration>
                    </execution>

            </executions>
            </plugin>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence 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"
    version="2.0">
    <persistence-unit name="C4OpenPU" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <non-jta-data-source>java:comp/env/jdbc/open_tomcat</non-jta-data-source>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.transaction.flush_before_completion" value="true"/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
            <property name="hibernate.connection.zeroDateTimeBehavior" value="convertToNull"/>
        </properties>
    </persistence-unit>

    <persistence-unit name="C4OpenTestPU" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
            <property name="hibernate.connection.username" value="sa" />
            <property name="hibernate.connection.password" value="" />
            <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:testOpen" />
            <property name="hibernate.default_schema" value="testLineopen"/>
        </properties>
    </persistence-unit>
</persistence>

The problem is when my test class is called during the test phase my schema didn’t seems to be existing. In the check-data execution the tables exists in the good schema.
Where is the problem ? Where are the tables ?

EDIT :
I also try with file database but it fails, problem of lock.
Database lock acquisition failure: lockFile.

Thanks you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:26:12+00:00Added an answer on May 27, 2026 at 7:26 pm

    The “Database lock acquisition failure” error you reported clearly indicates the tests are running in different JVM’s.

    Your best option for testing is an HSQLDB Server instance with the remote_open option. This option cretes a database (which can be an in-memory database) in the server when you make the first connection. See http://hsqldb.org/doc/2.0/guide/listeners-chapt.html for details and examples.

    If you are running the tests several times with the same Server instance, you can drop the schemas at the beginning of each run of the test suite.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web application using Spring and Tomcat 7.0. When I test
I'm developing an example web-application, using JPA 2.0 entities, Hibernate 3.6.2 and Spring 3.
I'm developing a web application using Spring, JSF 2 and Primefaces 3. I want
I'm developing a web application using Wicket+Spring+JPA+Hibernate. This is my first project with this
We are developing a web application using Spring framework and Hibernate ORM. As far
I'm developing a web application on Apache Tomcat 6 with Hibernate and Spring, I'm
I am using Spring Web MVC and Hibernate for developing my application. My login.jsp
I'm developping a web app, with jsf2,spring and hibernate. I have an application scoped
I am developing an application using SPRING 3.0.4, JPA 2, Hibernate 3.5.5. I an
I am developing a web application using Struts 2.1.2 and Hibernate 3.2.6.GA. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.