0

I am trying to write a maven script that drops and recreates an Oracle TimesTen database using sql-maven-plugin, and then apply a number of database migration scripts using dbdeploy during the pre-integration-test phase.

Both of these plugins require the use of the native timesten library which of course cannot be loaded by different classloaders, producing the following error:

[ERROR]
java.sql.SQLException: Problems with loading native library/missing methods: Native Library /opt/timesten/TimesTen/tt1122/lib/libttJdbcCS.dylib already loaded in another classloader

How can I overcome these issues in maven specifically?

For reference, my pom.xml is shown below:

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.xxx.xxx</groupId>
        <artifactId>xxx</artifactId>
        <version>x.x.x.x-SNAPSHOT</version>
    </parent>

    <groupId>x.x.x.x</groupId>
    <artifactId>db-reset</artifactId>

    <build>
        <plugins>
            <plugin>
                <groupId>com.dbdeploy</groupId>
                <artifactId>maven-dbdeploy-plugin</artifactId>
                <version>3.0M3</version>

                <configuration>
                    <scriptdirectory>src/sql/dbdeploy-migrations</scriptdirectory>
                    <driver>${timesten.jdbc.driver.class}</driver>
                    <url>${timesten.jdbc.url}</url>
                    <userid>${timesten.user}</userid>
                    <password>${timesten.password}</password>
                    <dbms>timesten</dbms>
                    <delimiter>;</delimiter>
                    <delimiterType>row</delimiterType>
                </configuration>

                <dependencies>
                    <dependency>
                        <groupId>com.timesten</groupId>
                        <artifactId>timesten</artifactId>
                        <version>11.2.2.7.8</version>
                        <scope>system</scope>
                        <systemPath>${timesten.jdbc.library.path}</systemPath>
                    </dependency>
                </dependencies>

                <executions>
                    <execution>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>update</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sql-maven-plugin</artifactId>
                <configuration>
                    <driver>${timesten.jdbc.driver.class}</driver>
                    <url>${timesten.jdbc.url}</url>
                    <username>${timesten.user}</username>
                    <password>${timesten.password}</password>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.timesten</groupId>
                        <artifactId>timesten</artifactId>
                        <version>11.2.2.7.8</version>
                        <scope>system</scope>
                        <systemPath>${timesten.jdbc.library.path}</systemPath>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>drop-db</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <onError>continue</onError>
                            <srcFiles>
                                <srcFile>src/sql/base/drop.sql</srcFile>
                            </srcFiles>
                        </configuration>
                    </execution>
                    <execution>
                        <id>create-clean-db</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <srcFiles>
                                <srcFile>src/sql/base/create.sql</srcFile>
                            </srcFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
curtisjk
  • 1
  • 2

1 Answers1

0

In case this is still interesting: you can solve this by creating a small maven-plugin with a Mojo that does nothing but Class.forName() the Plugin class. Create a META-INF/maven/extensions.xml that exports the package of the driver as an extension. Run this plugin very early (e.g. during initialization) and specifiy

<extensions>true</extensions>

Effectively, the extension creates a classloader shared by all plugins with the driver class loaded once (and the native library loaded once).