Liquibase failing when running cobertura reports

Hello there:

I’ve been happily using liquibase with Maven for quite a while now, but started observing some problems as soon as I enabled cobertura report generation.

I have a single-module Maven project.  In my pom.xml, I have liquibase configured as follows:

        org.liquibase     liquibase-plugin     1.9.3.0             production-db     process-resources         src/main/resources/liquibase.properties             update                 test-db     test-compile         src/test/resources/liquibase.properties             update            

Under the directory src/main/resources I have the file �liquibase.properties� with the following contents:

    username=dev password=dev url=jdbc:mysql://localhost/prod_db driver=com.mysql.jdbc.Driver changeLogFile=dbChangeLog.xml

Also, under the same directory (src/main/resources) I have my dbChangeLog.xml file.

I have a similar setting for my test database: under src/test/resources I have a liquibase.properties file with the same contents as the one shown above (except that the database is �test_db� instead of �prod_db�).

Everything works really well whenever I run a regular build:

mvn clean install

Both of my databases are updated as expected; I can see from the logs that liquibase is finding the dbChangeLog.xml for both update executions, as specified in the pom.xml.

Now, I want to generate reports for my build, so I added the following section at the end of my pom.xml:

                            org.codehaus.mojo             cobertura-maven-plugin            

Running a regular build still works as before, however, if a run a site build (to trigger report generation):

mvn clean install site

I see liquibase executing successfully on the first pass of the build, but fails on the second pass with the error:

[INFO] Executing on Database: jdbc:mysql://localhost/prod_db                                                                                   

2-Jun-2009 10:10:41 AM liquibase.database.template.JdbcTemplate comment                                                                           
INFO: Lock Database                                                                                                                               
2-Jun-2009 10:10:41 AM liquibase.lock.LockHandler acquireLock                                                                                     
INFO: Successfully acquired change log lock                                                                                                       
2-Jun-2009 10:10:41 AM liquibase.database.template.JdbcTemplate comment                                                                           
INFO: Release Database Lock                                                                                                                       
2-Jun-2009 10:10:41 AM liquibase.lock.LockHandler releaseLock                                                                                     
INFO: Successfully released change log lock                                                                                                       
2-Jun-2009 10:10:41 AM liquibase.database.template.JdbcTemplate comment                                                                           
INFO: Release Database Lock                                                                                                                       
2-Jun-2009 10:10:41 AM liquibase.lock.LockHandler releaseLock                                                                                     
INFO: Successfully released change log lock                                                                                                       
[INFO] ------------------------------------------------------------------------                                                                   
[ERROR] BUILD ERROR                                                                                                                               
[INFO] ------------------------------------------------------------------------                                                                   
[INFO] Error setting up or running Liquibase: dbChangeLog.xml does not exist                                                                     

[INFO] ------------------------------------------------------------------------
[DEBUG] Trace                                                                 
org.apache.maven.lifecycle.LifecycleExecutionException: Error setting up or running Liquibase: dbChangeLog.xml does not exist
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:924)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:767)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:549)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: dbChangeLog.xml does not exist
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:194)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        … 20 more
Caused by: liquibase.exception.ChangeLogParseException: dbChangeLog.xml does not exist
        at liquibase.parser.xml.XMLChangeLogParser.parse(XMLChangeLogParser.java:65)
        at liquibase.parser.ChangeLogParser.parse(ChangeLogParser.java:28)
        at liquibase.Liquibase.update(Liquibase.java:105)
        at org.liquibase.maven.plugins.LiquibaseUpdate.doUpdate(LiquibaseUpdate.java:19)
        at org.liquibase.maven.plugins.AbstractLiquibaseUpdateMojo.performLiquibaseTask(AbstractLiquibaseUpdateMojo.java:23)
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:190)
        … 22 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 55 seconds
[INFO] Finished at: Tue Jun 02 10:10:41 EDT 2009
[INFO] Final Memory: 24M/44M
[INFO] ------------------------------------------------------------------------

Why is the liquibase plugin not finding my dbChangeLog.xml when executing a site when it can clearly find it when running a normal build?

Any help will be greatly appreciated.

Thanks in advance.

I think I found my problem.  The cobertura-maven-plugin has a custom life-cycle that starts with resources:resources.  This is the goal in the maven-resources-plugin responsible for copying all the resources under src/main/resources to the target (output) destination.  I was binding the �update� goal of the liquibase plugin to �process-resources�, which seems to also do the same thing (ie copy resources):

      production-db   process-resources           src/main/resources/liquibase.properties                           update        

So my guess is that because both goals were bound to the same phase, no particular order was being enforced, thus �liquibase:update� was running before �resources:resources�.  As a result, liquibase was looking for the dbChangeLog.xml file, but this file had not being copied to the output directory yet.

Binding liquibase:update goals to a later phase in the life-cycle seems to have solved my problem; for the sake of future reference, here’s the updated plugin configuration in my pom.xml:

        org.liquibase     liquibase-plugin     1.9.3.0         production-db     process-classes     src/main/resources/liquibase.properties         update         test-db     test-compile     src/test/resources/liquibase.properties         update        
I don't think the liquibase plugin has anything to do with this, but the error seemed to imply that.  Sorry for the false alarm...

Thanks for the update.  I’m not a maven user, does it make sense to modify the standard plugin orbis it fine like it is?

Nathan

Bonjour.

J’avais un problème similaire.
Pour compléter ton analyse.
Tu bind ton execution de liquibase à la phase process-resources, hors je vois que tu utilises un fichier liquibase.properties qui est dans sr/test/resources (et donc je suppose que ton change log est aussi dans ce répertoires) => il faudrait que tu bind ton execution sur la phase process-test-resources, sans quoi les resources de test ne sont pas processés.
J’ai fait le test chez moi et ca a corrigé mon pb.

J’espère que ca te sera utile.