Skip to content

jhirn/maven-exec-jdbcdriver-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

**Update 2/12/2010 (15 minutes later)**

Created an ant build file which recreates the problem all the same (thanks mvn ant:ant). So Maven is off the hook although exec:java should allow you to fork the JVM. Forking the JVM in ant resolves the problem. 

The following ant targets are of interest:

ant
ant execute-main
ant execute-main-forked

I think this is more ClassLoader issues than anyone should have to deal with. =( 

**Update 2/12/2010**

So the problem gets a little more weird. It turns out that the 2nd call to DriverManager.getDrivers() will also create this issue. 

Time to try a build.xml, I might be able to rule Maven out of this one. Even if it means touching Ant again =(. 

**Original Read Me**

This project demonstrates a problem I experienced today when trying to use the maven-exec plugin after executing the maven-sql-plugin. What seemed to be happening was that maven-sql-plugin was unloading jdbc drivers after execution. I have successfully used dbunit-plugin after maven-sql-plugin but moved to using the maven-exec plugin for programatic execution of dbunit after using Gunnar Morling excellent Scriptable Dataset adapter for dynamic values via Groovy. (See more about the Scriptable Dataset here: http://github.com/gunnarmorling/scriptable-dataset).

After boiling it down, I was able to recreate this issue even without the maven-sql-plugin. The project here will use the JDBC DriverManager.getDrivers() to enumerate and print out the drivers that are loaded. The first time it is ran, it prints out two drivers (sun jdbc-odbc and h2). The second execution of the code will have only one driver loaded (sun-jdbc-odbc). 

To see the problem, simply git the source and run `mvn compile`.

As I mentioned, if you run the maven-sql-plugin prior to the maven-exec, the h2 driver will not be loaded either. I've added the profiles to demonstrate this. You can see it by running:

mvn compile -Pexec-then-sql
mvn compile -Psql-then-exec

You will notice that exec-then-sql will print out two drivers and sql-then-exec will only print out one. 

I'm not sure if this is a defect in the maven-exec, maven or if it's a werid jdbc driver thing that's somehow normal.  I figured I'd put it up here incase someone felt like looking at it. I'd love to hear what's going on and would be more than willing to assist with patching but want to confirm I'm not just going crazy. 

This is happening on windows 7 but also happens on my work box using XP. 

Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500)
Java version: 1.6.0_16
Java home: C:\Java\jdk1.6.0_16\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"

About

Manifestation of a probelm I found with maven-sql-plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages