Issue Details (XML | Word | Printable)

Key: APF-606
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matt Raible
Reporter: Anno Langen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse

dbunit CLEAN_INSERT tries to execute before hbm2dll

Created: 31/Jan/07 11:13 AM   Updated: 05/Feb/07 05:00 PM   Resolved: 05/Feb/07 05:00 PM
Component/s: Build, Test, or Deploy Process
Affects Version/s: 2.0-M2
Fix Version/s: 2.0-M3

Environment: Starting from scratch, with MSQL installed but database not yet created
Issue Links:
Duplicate
 


 Description  « Hide
Dbunit tries to execute before hbm2dll. They are both configured to run in test-compile and I don't know how to order goals in the same phase. Changing the phase of hbm2dll to "process-classes" solves the problem and seems more correct. Such a change would better support for "mvn jetty:run", which lacks a test phase.

To reproduce the problem, start with a new database, either drop database, appfuse, or edit the jdbc url in pom.xml before running mvn jetty:run-war
Then follow these steps from the README:

mvn archetype:create -DarchetypeGroupId=org.appfuse -DarchetypeArtifactId=appfuse-basic-spring -DremoteRepositories=http://static.appfuse.org/repository -DarchetypeVersion=1.0-m2 -DgroupId=com.mycompany -DartifactId=myapp
cd myapp
mvn jetty:run-war

This fails with ...
[INFO] [dbunit:operation {execution: default}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing database operation: CLEAN_INSERT

Embedded error: user_role





Sort Order: Ascending order - Click to sort in descending order
Anno Langen added a comment - 31/Jan/07 11:21 AM
Changing the phase of hbm2dll also appears to solve a second lifecycle problem that I find more difficult to distill. "mvn site" failed with ClassNotFoundError for new entries in hibernate.cfg.xml when hbm2dll was running after cobertura.


Matt Raible added a comment - 31/Jan/07 01:17 PM
Changing the hibernate3 plugin to use the "process-test-resources" phase seems like the most appropriate fix - as it executes just before "test-compile". BTW, in the most recent versions of AppFuse 2.x, the dbunit plugin is executed twice:

                <executions>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>operation</goal>
                        </goals>
                    </execution>
                    <execution>
                        <!-- Runs before integration tests and jetty:run-war -->
                        <id>test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>operation</goal>
                        </goals>
                    </execution>
                </executions>

According to the Maven team, order is not guaranteed for plugins that use the same phase.

Anno Langen added a comment - 31/Jan/07 02:54 PM
I just confirmed that process-test-resources does solves the problem I reported. But unlike phase, process-classes, it does not solve my other Maven life cycle problem. It is "mvn site" when the application has defined an additional model class. Why not process-classes? The description of that phase in http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html seems to fit.

And finally, there is the support for edit/compile without unit testing, which "mvn jetty:run" would enable if the schema were altered as part of process-classes.


Matt Raible added a comment - 31/Jan/07 03:22 PM
I'll change it to "process-classes", but I don't understand why it causes a problem with mvn site and mvn jetty:run. All this plugin does is generate a database tables. I almost wish it didn't run if the database tables existed since it spits out a ton of output.

Anno Langen added a comment - 31/Jan/07 04:14 PM
I don't understand the problem with mvn site either, but the phase of hbm2dll is a trigger.

As for jetty:run, I now see that hbm2dll does not alter tables, it merely tries to create them. Plus it turns out jetty:run requires "compile" but not "process-classes". Please forget my jetty:run argument.

Maybe I should just deviate in my project's copy of pom.xml until I understand the deeper problem with mvn site.

Matt Raible added a comment - 31/Jan/07 06:26 PM
Changed phase to process-classes for now - please let me know if process-test-resources turns out to be the better solution.

Matt Raible added a comment - 31/Jan/07 06:40 PM
Reopening since process-classes phase causes the following issue with the hibernate module:

[INFO] target/test-classes/jdbc.properties not found within the project. Trying absolute path.
[INFO] No hibernate properties file loaded.
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The dialect was not set. Set the property hibernate.dialect.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.

Changing to process-test-resources should fix this problem.