Reputation: 21
I'm trying to use flyway on a complex ERP with multiple databases, but I didn't find any hint to make it runs. I'm using an ant script together with Hudson to build the whole system. So, I created a migrate.xml file with the contents below and call the script multiple times at tasks the below. However, the task runs with any errors only once. If I call the task twice, an exception is thrown. Any idea to solve the problem?
Thanks in advance.
--exception
BUILD FAILED
/home/raphael/Development/ufpb/sig/sig-migration-fly-way/build.xml:6: The following error occurred while executing this line:
/home/raphael/Development/ufpb/sig/sig-migration-fly-way/migrate.xml:27: Flyway Error: java.lang.IllegalArgumentException: null source
at java.util.EventObject.<init>(EventObject.java:38)
at org.apache.tools.ant.BuildEvent.<init>(BuildEvent.java:93)
at org.apache.tools.ant.Project.fireMessageLogged(Project.java:2351)
at org.apache.tools.ant.Project.log(Project.java:492)
at com.googlecode.flyway.ant.AntLog.debug(AntLog.java:42)
at com.googlecode.flyway.core.dbsupport.DbSupportFactory.createDbSupport(DbSupportFactory.java:59)
at com.googlecode.flyway.core.Flyway.execute(Flyway.java:1159)
at com.googlecode.flyway.core.Flyway.info(Flyway.java:967)
at com.googlecode.flyway.ant.MigrateTask.doExecuteWithMigrationConfig(MigrateTask.java:157)
at com.googlecode.flyway.ant.AbstractMigrationLoadingTask.doExecute(AbstractMigrationLoadingTask.java:271)
at com.googlecode.flyway.ant.AbstractFlywayTask.execute(AbstractFlywayTask.java:329)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
--task
<target name="test">
<ant antfile="migrate.xml">
<property name="dir" value="sigaa"/>
<property name="database" value="demo_development"/>
</ant>
</target>
---migrate.xml
<?xml version="1.0"?>
<project name="migrations" default="deploy" basedir="." xmlns:flyway="antlib:com.googlecode.flyway.ant">
<path id="flyway.classpath">
<!-- include all jars containing jdbc drivers -->
<!-- include all jars and directories containing sql migrations -->
<!-- include all jars and directories containing compiled java migrations -->
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef uri="antlib:com.googlecode.flyway.ant"
resource="com/googlecode/flyway/ant/antlib.xml" />
<property name="flyway.driver" value="org.postgresql.Driver"/>
<property name="flyway.initOnMigrate" value="true"/>
<property name="flyway.validateOnMigrate" value="true"/>
<property name="flyway.url" value="jdbc:postgresql://localhost:5432/${database}"/>
<property name="flyway.user" value="***"/>
<property name="flyway.password" value="****"/>
<property name="flyway.table" value="schema_version_${dir}"/>
<property name="flyway.locations" value="filesystem:db/migrations/${dir}"/>
<target name="migrate">
<flyway:migrate />
</target>
<target name="deploy" depends="migrate">
<flyway:info />
</target>
</project>
Upvotes: 1
Views: 1588
Reputation: 21
The problem was in class com.googlecode.flyway.ant.AntLog of flyway-ant project, because of log method of org.apache.tools.ant.Project class. On the second time of execution, the code antProject.getThreadTask(Thread.currentThread()) returns null and the error occurs. I put an if statement to solve the problem like the code below
if (task != null)
antProject.log(task, message, null, Project.MSG_VERBOSE);
else
antProject.log(message, null, Project.MSG_VERBOSE);
Upvotes: 1