bmatthews68 / inmemdb-maven-plugin

A Maven 3 plug-in that can be used to launch an in-memory database for use in integration tests. Apache Derby and HSQLDB are both supported.
http://inmemdb-maven-plugin.btmatthews.com
Apache License 2.0
15 stars 7 forks source link

Hsqldb is mandatory even if we're using derby #19

Closed Tcharl closed 10 years ago

Tcharl commented 10 years ago

Even if using derby, a noclassdeffound appears at shutdown: Exception in thread "Thread-1" java.lang.NoClassDefFoundError: org/hsqldb/DatabaseURL at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source) at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:215) at com.btmatthews.maven.plugins.inmemdb.db.derby.DerbyDatabase.stop(DerbyDatabase.java:207) at com.btmatthews.utils.monitor.Monitor.executeCommand(Monitor.java:265) at com.btmatthews.utils.monitor.Monitor.runMonitorInternal(Monitor.java:180) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:128) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:152) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: org.hsqldb.DatabaseURL at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227) ... 10 more

bmatthews68 commented 10 years ago

Could you please attached the definition for inmemdb from your POM? Thanks, Brian

On 13 May 2014 19:32, Charlie Mordant notifications@github.com wrote:

Even if using derby, a noclassdeffound appears at shutdown: Exception in thread "Thread-1" java.lang.NoClassDefFoundError: org/hsqldb/DatabaseURL at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source) at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:215) at com.btmatthews.maven.plugins.inmemdb.db.derby.DerbyDatabase.stop(DerbyDatabase.java:207) at com.btmatthews.utils.monitor.Monitor.executeCommand(Monitor.java:265) at com.btmatthews.utils.monitor.Monitor.runMonitorInternal(Monitor.java:180) at com.btmatthews.utils.monitor.Monitor.runMonitor(Monitor.java:128) at com.btmatthews.utils.monitor.Monitor$1.run(Monitor.java:152) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: org.hsqldb.DatabaseURL at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227) ... 10 more

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/19 .

Tcharl commented 10 years ago

Hi Brian, it's a pleasure :). Your framework looks good for my use case and in its entire phylosophy, in particular with Liquibase. Can I suggest a use case? I've got a production database, and I modified the structure of my Dev one, combining liquibase-m-plug with inmemdb one while deploying from dev to prod (or test, whatever). First step, launch a data empty inmemdb with the same structure as the prod one: to have a data diff

Then, launch an in-mem db with the modified structure to have the struct diff with the prod one:

<plugin>
                        <groupId>org.liquibase</groupId>
                        <artifactId>liquibase-maven-plugin</artifactId>
                        <version>${liquibase.version}</version>
                        <configuration>
                            <propertyFile>target/classes/liquibase-diff.properties</propertyFile>
                            <changeLogFile>target/classes/db/db.changelog.xml</changeLogFile>
                            <diffChangeLogFile>src/main/resources/db/db-${timestamp}.changelog.xml</diffChangeLogFile>
                            <logging>info</logging>
                        </configuration>
                        <executions>
                            <execution>
                                <id>generate-db-diff</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>diff</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>${jdbc.groupId}</groupId>
                                <artifactId>${jdbc.artifactId}</artifactId>
                                <version>${jdbc.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>org.apache.derby</groupId>
                                <artifactId>derbynet</artifactId>
                                <version>${derby.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>org.apache.derby</groupId>
                                <artifactId>derby</artifactId>
                                <version>${derby.version}</version>
                            </dependency>

Finally, with the first sql generated data diff and the new prod structure, we can play with regexp to make the old data compliant with our new db configuration!

So here's my pom config for the ticket:

<plugin>
                <groupId>com.btmatthews.maven.plugins.inmemdb</groupId>
                <artifactId>inmemdb-maven-plugin</artifactId>
                <version>1.4.2</version>
                <configuration>
                    <monitorPort>11527</monitorPort>
                    <monitorKey>mmemory</monitorKey>
                    <type>derby</type>
                    <database>${project.artifactId}</database>
                    <username>${jdbc.username}</username><!-- i.e. SA -->
                    <password>${jdbc.password}</password><!-- i.e. SA -->
                </configuration>
                <executions>
                    <execution>
                        <id>start-inmemdb</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <daemon>true</daemon>
                            <sources>
                                <script>
                                    <sourceFile>${project.build.directory}/${project.artifactId}.sql</sourceFile>
                                </script>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-inmemdb</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.derby</groupId>
                        <artifactId>derbyclient</artifactId>
                        <version>${derby.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.derby</groupId>
                        <artifactId>derbynet</artifactId>
                        <version>${derby.version}</version>
                    </dependency> 
                    <dependency>
                        <groupId>org.apache.derby</groupId>
                        <artifactId>derby</artifactId>
                        <version>${derby.version}</version><!-- derby version is 10.10.2.0, see https://github.com/bmatthews68/inmemdb-maven-plugin/issues/18-->
                    </dependency>
                    <!-- <dependency> throws exception if commented
                        <groupId>org.hsqldb</groupId>
                        <artifactId>hsqldb</artifactId>
                        <version>1.8.0.10</version>
                    </dependency>
                     -->
                </dependencies>
            </plugin>

Best Regards, Charlie,

bmatthews68 commented 10 years ago

Hi Charlie,

I believe the problem you are experiencing is caused by your inclusion of the derby dependencies. The inmemdb-maven-plugin is resolving the necessary dependencies internally. So there is no need to included them in the plugin. But I never actually tested to see what would happen if they are included and I guess there is a conflict.

For now you should just remove the section from the section. And I'll look at improving the dependency resolution so that it allows you to override the dependencies in the plugin definition.

I've not encountered liquibase before. Its a clever use case you've come up with and I think I'd like to familiarise myself with liquibase and incorporate your use case into the documentation.

Thanks, Brian

On 14 May 2014 21:48, Charlie Mordant notifications@github.com wrote:

Hi Brian, it's a pleasure :). Your framework looks good for my use case and in its entire phylosophy, in particular with Liquibase. Can I suggest a use case? I've got a production database, and I modified the structure of my Dev one, combining liquibase-m-plug with inmemdb one while deploying from dev to prod (or test, whatever). First step, launch a data empty inmemdb with the same structure as the prod one: to have a data diff

Then, launch an in-mem db with the modified structure to have the struct diff with the prod one:

org.liquibase liquibase-maven-plugin ${liquibase.version} target/classes/liquibase-diff.properties target/classes/db/db.changelog.xml src/main/resources/db/db-${timestamp}.changelog.xml info generate-db-diff process-test-resources diff ${jdbc.groupId} ${jdbc.artifactId} ${jdbc.version} org.apache.derby derbynet ${derby.version} org.apache.derby derby ${derby.version} Finally, with the first sql generated data diff and the new prod structure, we can play with regexp to make the old data compliant with our new db configuration! So here's my pom config for the ticket: com.btmatthews.maven.plugins.inmemdb inmemdb-maven-plugin 1.4.2 11527 mmemory derby ${project.artifactId} ${jdbc.username} ${jdbc.password} start-inmemdb initialize run true stop-inmemdb prepare-package stop org.apache.derby derbyclient ${derby.version} org.apache.derby derbynet ${derby.version} org.apache.derby derby ${derby.version} Best Regards, Charlie, — Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/19#issuecomment-43135425 .
bmatthews68 commented 10 years ago

Hi Charlie,

My last comment actually related to some unreleased work that I've now moved to the 2.0.0 development branch. There would definitely be an issue if you uncommented the hsqldb dependency in your POM because the plugin was updated to work with the 2.x.x version of hsqldb.

I've made a 1.4.3 release which uses derby 10.10.2.0 and hsqldb 2.3.2.

Tcharl commented 10 years ago

Cool, thank you for your reactivity! I'll try this tonight (I'll implement the preceding use case in Osgiliath framework if a day you'll take a look at it ;) ) Regards

Tcharl commented 10 years ago

Hi Brian,

It looks like you didn't fully released the 1.4.3 (its tagged on github but not available on central). Have you promoted your release on sonatype-staging?

Regards,

bmatthews68 commented 10 years ago

I'll fix that up after I finish class this morning. On 17 May 2014 09:32, "Charlie Mordant" notifications@github.com wrote:

Hi Brian,

It looks like you didn't fully released the 1.4.3 (its tagged on github but not available on central). Have you promoted your release on sonatype-staging?

Regards,

— Reply to this email directly or view it on GitHubhttps://github.com/bmatthews68/inmemdb-maven-plugin/issues/19#issuecomment-43401304 .