Issue Details (XML | Word | Printable)

Key: APF-1073
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matt Raible
Reporter: jessie evangelista
Votes: 2
Watchers: 3
Operations

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

Profiles seem to be broken in Appfuse 2.0.2, Error executing database operation: CLEAN_INSERT

Created: 21/May/08 06:07 PM   Updated: 12/Dec/08 01:13 AM   Resolved: 12/Dec/08 01:13 AM
Component/s: Build, Test, or Deploy Process
Affects Version/s: 2.0.2
Fix Version/s: 2.1.0-M1

Environment:
For reference, mvn -version

Maven version: 2.0.9
Java version: 1.5.0_14
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"


 Description  « Hide
Profiles seem to be broken in 2.0.2

created project using:
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

tried running with h2:
mvn -Ph2

Output:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building AppFuse Spring MVC Application
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [warpath:add-classes {execution: default}]
[INFO] [aspectj:compile {execution: default}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}]
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] Preparing hibernate3:hbm2ddl
[WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive invocati
on.
[INFO] [warpath:add-classes {execution: default}]
[INFO] [aspectj:compile {execution: default}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}]
[INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}]
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[WARNING] POM for 'org.hibernate:jtidy:pom:r8-20060801:runtime' is invalid. It w
ill be ignored for artifact resolution. Reason: Parse error reading POM. Reason:
 TEXT must be immediately followed by END_TAG and not START_TAG (position: START
_TAG seen ...<licenses>\n\t\t\t<license>... @12:13) for project org.hibernate:j
tidy at C:\Documents and Settings\jess\.m2\repository\org\hibernate\jtidy\r8-200
60801\jtidy-r8-20060801.pom
[INFO] [hibernate3:hbm2ddl {execution: default}]
[INFO] Configuration XML file loaded: file:/D:/java/smetrix_workspace/myproject/
src/main/resources/hibernate.cfg.xml
[INFO] Configuration XML file loaded: file:/D:/java/smetrix_workspace/myproject/
src/main/resources/hibernate.cfg.xml
[INFO] Configuration Properties file loaded: D:\java\smetrix_workspace\myproject
\target\classes\jdbc.properties
alter table user_role drop constraint FK143BF46AF503D155;
alter table user_role drop constraint FK143BF46A4FD90D75;
drop table app_user if exists;
drop table role if exists;
drop table user_role if exists;
create table app_user (id bigint generated by default as identity, account_expir
ed bit not null, account_locked bit not null, address varchar(150), city varchar
(50) not null, country varchar(100), postal_code varchar(15) not null, province
varchar(100), credentials_expired bit not null, email varchar(255) not null uniq
ue, account_enabled bit, first_name varchar(50) not null, last_name varchar(50)
not null, password varchar(255) not null, password_hint varchar(255), phone_numb
er varchar(255), username varchar(50) not null unique, version integer, website
varchar(255), primary key (id));
create table role (id bigint generated by default as identity, description varch
ar(64), name varchar(20), primary key (id));
create table user_role (user_id bigint not null, role_id bigint not null, primar
y key (user_id, role_id));
alter table user_role add constraint FK143BF46AF503D155 foreign key (user_id) re
ferences app_user;
alter table user_role add constraint FK143BF46A4FD90D75 foreign key (role_id) re
ferences role;
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [dbunit:operation {execution: test-compile}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing database operation: CLEAN_INSERT

Embedded error: user_role
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22 seconds
[INFO] Finished at: Thu May 22 07:00:45 CST 2008
[INFO] Final Memory: 21M/39M
[INFO] ------------------------------------------------------------------------


jessie evangelista added a comment - 22/May/08 01:31 AM
Just did some more tests.

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.







Matt Raible made changes - 22/May/08 07:52 AM
Field Original Value New Value
Fix Version/s 2.1 [ 10031 ]
Matt Raible added a comment - 29/May/08 08:32 AM
I was unable to reproduce this on OS X as well. I'll look into reproducing on Windows in the near future.

Jeff Smith added a comment - 10/Jun/08 02:38 AM
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.

ssarando added a comment - 09/Oct/08 09:51 AM
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.

ssarando added a comment - 09/Oct/08 01:12 PM
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

3187 by  Matt Raible (14 files)
12/Dec/08 01:11 AM (20 months, 9 days ago)
Exclude ApplicationResources*.properties from war overlay (in case the WAR has newer files). Also fixed APF-1073 - replacing ${java.io.tmpdir} with /tmp.
appfuse: trunk/archetypes/appfuse-core/src/main/resources/archetype-resources/pom.xml 3187 history download (+2 -2) diffs
appfuse: trunk/archetypes/appfuse-modular-spring/src/main/resources/archetype-resources/pom.xml 3187 history download (+2 -2) diffs
appfuse: trunk/archetypes/appfuse-basic-struts/src/main/resources/archetype-resources/pom.xml 3187 history download (+4 -3) diffs
appfuse: trunk/archetypes/appfuse-modular-jsf/src/main/resources/archetype-resources/pom.xml 3187 history download (+2 -2) diffs
appfuse: trunk/archetypes/appfuse-basic-jsf/src/main/resources/archetype-resources/pom.xml 3187 history download (+4 -3) diffs
appfuse: trunk/archetypes/appfuse-modular-tapestry/src/main/resources/archetype-resources/web/pom.xml 3187 history download (+2 -1) diffs
appfuse: trunk/archetypes/appfuse-basic-spring/src/main/resources/archetype-resources/pom.xml 3187 history download (+4 -3) diffs
appfuse: trunk/archetypes/appfuse-modular-struts/src/main/resources/archetype-resources/pom.xml 3187 history download (+2 -2) diffs
appfuse: trunk/pom.xml 3187 history download (+2 -2) diffs
appfuse: trunk/archetypes/appfuse-modular-jsf/src/main/resources/archetype-resources/web/pom.xml 3187 history download (+2 -1) diffs
appfuse: trunk/archetypes/appfuse-modular-spring/src/main/resources/archetype-resources/web/pom.xml 3187 history download (+2 -1) diffs
appfuse: trunk/archetypes/appfuse-basic-tapestry/src/main/resources/archetype-resources/pom.xml 3187 history download (+4 -3) diffs
appfuse: trunk/archetypes/appfuse-modular-tapestry/src/main/resources/archetype-resources/pom.xml 3187 history download (+2 -2) diffs
appfuse: trunk/archetypes/appfuse-modular-struts/src/main/resources/archetype-resources/web/pom.xml 3187 history download (+2 -1) diffs

Matt Raible added a comment - 12/Dec/08 01:13 AM
Changed ${java.io.tmpdir} to /tmp.

Matt Raible made changes - 12/Dec/08 01:13 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]