|
Matt Raible made changes - 22/May/08 07:52 AM
I was unable to reproduce this on OS X as well. I'll look into reproducing on Windows in the near future.
I have the exact same problem on windows XP (Appfuse 2.0.2, maven 2.0.9, jdk 1.5.0_05).
I tried with both the h2 and hsqldb profiles (which use the java.io.tmpdir) and got similar errors. When I tried the workaround suggested by jessie (replace java.io.tmpdir with a specific directory) everything worked fine. I have run into the same issue with both the H2 and HSQLDB databases. It appears to be a problem with backslashes in the path returned for "java.io.tmpdir" on Windows (I am running Vista). When I ran the application ("mvn jetty:run"), the initial database is created and populated by hbm2ddl in a folder named "UsersUserAppDataLocal" under the project folder, instead of my temp folder "C:\Users\User\AppData\Local" (the path returned by the "java.io.tmpdir" property). When the dbunit goal runs it creates the database again (since it didn't find it) in "C:\Users\User\AppData\Local" but then complains that tables don't exists because it's not using the database created earlier by hbm2ddl.
Initially, it looks like hbm2ddl, or the wrapping Maven plugin, is removing the backslashes from the path and concatenating the directory names together. When I hardcode the path to my temp folder using forward slashes instead, as in "C:/Users/User/AppData/Local", it works fine. The problem is caused by the behavior of the load() method in java.util.Properties. From the JDK docs:
----------------------- public void load(InputStream inStream) throws IOException ... The method does not treat a backslash character, \, before a non-valid escape character as an error; the backslash is silently dropped. For example, in a Java string the sequence "\z" would cause a compile time error. In contrast, this method silently drops the backslash. Therefore, this method treats the two character sequence "\b" as equivalent to the single character 'b'. ----------------------- As configured, the hibernate3 plugin is loading the jdbc.properties file, whereas the dbunit plugin is being configured using variable replacement in pom.xml. This isn't technically an AppFuse problem. The backslashes need to be escaped (doubled) in the hibernate3 plugin, for instance, the way the Maven resources plugin handles them: http://maven.apache.org/plugins/maven-resources-plugin/xref/org/apache/maven/plugin/resources/ReflectionProperties.html#62
Exclude ApplicationResources*.properties from war overlay (in case the WAR has newer files). Also fixed
Changed ${java.io.tmpdir} to /tmp.
Matt Raible made changes - 12/Dec/08 01:13 AM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
Tried it on an ubunu box:
Outpun of mvn -v:
Maven version: 2.0.9
Java version: 1.5.0_15
OS name: "linux" version: "2.6.18.8-domu-linode7" arch: "i386" Family: "unix"
Command used to create the project:
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject
Command used to test: mvn test -Ph2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17 seconds
[INFO] Finished at: Thu May 22 00:32:58 GMT-05:00 2008
[INFO] Final Memory: 21M/39M
[INFO] ------------------------------------------------------------------------
This means it works on Linux.
Poking around the pom file, I noticed that the h2 database will be created in the java io tmp directory. I changed this value to ${dbtempdir}
and defined a property: <dbtempdir>temp</dbtempdir>.
This fixed the error for me but the side effect is that a temp directory was created inside the project directory.