Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 2.1.0
-
Fix Version/s: 2.2.1
-
Component/s: Installation
-
Labels:None
-
Environment:Tested to have the same effect on Windows 7 and Windows XP. Both with MySQL, jdk1.6.0_26, apache-maven-2.2.1.
Description
Basic archetype creation results in database error when doing a mvn install.
Should be easy to reproduce (I have done it several times).
First create a project using the Quickstart method:
C:\Project>mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts-archetype -DarchetypeVersion=2.1.0 -DgroupId=com.mycompany -DartifactId=full -DarchetypeRepository=http://oss.sonatype
.org/content/repositories/appfuse
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] [archetype:generate
]
[INFO] Generating project in Batch mode
[INFO] Archetype defined by properties
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: appfuse-basic-struts-archetype:2.1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: artifactId, Value: full
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mycompany
[INFO] Parameter: packageInPathFormat, Value: com/mycompany
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.mycompany
[INFO] Parameter: groupId, Value: com.mycompany
[INFO] Parameter: artifactId, Value: full
[INFO] project created from Archetype in dir: C:\Project\full
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Fri Feb 03 09:25:12 EST 2012
[INFO] Final Memory: 19M/47M
[INFO] ------------------------------------------------------------------------
That seems to work fine.
Now go into the project and:
C:\Project>cd full
C:\Project\full>mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building AppFuse Struts 2 Application
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [native2ascii:native2ascii
]
[INFO] [native2ascii:native2ascii
]
[INFO] [resources:resources
]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 37 resources
[INFO] Copying 16 resources
[INFO] Copying 8 resources
[INFO] Copying 16 resources
[INFO] Copying 16 resources
[INFO] [compiler:compile
]
[INFO] Compiling 20 source files to C:\Project\full\target\classes
[INFO] [resources:testResources
]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] Copying 11 resources
[INFO] Preparing hibernate3:hbm2ddl
[WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive invocation.
[INFO] [native2ascii:native2ascii
]
[INFO] [native2ascii:native2ascii
]
[INFO] [resources:resources
]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 37 resources
[INFO] Copying 16 resources
[INFO] Copying 8 resources
[INFO] Copying 16 resources
[INFO] Copying 16 resources
[INFO] Copying 16 resources
[INFO] Copying 16 resources
[INFO] [hibernate3:hbm2ddl
]
[INFO] Configuration XML file loaded: file:/C:/Project/full/src/main/resources/hibernate.cfg.xml
[INFO] Configuration XML file loaded: file:/C:/Project/full/src/main/resources/hibernate.cfg.xml
[INFO] Configuration Properties file loaded: C:\Project\full\target\classes\jdbc.properties
alter table user_role drop foreign key FK143BF46A4FD90D75;
alter table user_role drop foreign key FK143BF46AF503D155;
drop table if exists app_user;
drop table if exists role;
drop table if exists user_role;
create table app_user (id bigint not null auto_increment, account_expired bit not null, account_locked bit not null, address varchar(150), city varchar(50), country varchar(100), postal_code varchar(15), province varchar(100), credentials_e
xpired bit not null, email varchar(255) not null unique, 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_number varchar(255), username v
archar(50) not null unique, version integer, website varchar(255), primary key (id)) ENGINE=InnoDB;
create table role (id bigint not null auto_increment, description varchar(64), name varchar(20), primary key (id)) ENGINE=InnoDB;
create table user_role (user_id bigint not null, role_id bigint not null, primary key (user_id, role_id)) ENGINE=InnoDB;
alter table user_role add index FK143BF46A4FD90D75 (role_id), add constraint FK143BF46A4FD90D75 foreign key (role_id) references role (id);
alter table user_role add index FK143BF46AF503D155 (user_id), add constraint FK143BF46AF503D155 foreign key (user_id) references app_user (id);
[WARNING] 2 errors occurred while performing <hbm2ddl>.
[ERROR] Error #1: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'full.user_role' doesn't exist
[ERROR] Error #1: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'full.user_role' doesn't exist
[INFO] [compiler:testCompile
]
[INFO] Compiling 7 source files to C:\Project\full\target\test-classes
[INFO] [dbunit:operation
]
98 [main] INFO org.dbunit.database.DatabaseDataSet -
database name=MySQL
database version=5.5.17
database major version=5
database minor version=5
jdbc driver name=MySQL-AB JDBC Driver
jdbc driver version=mysql-connector-java-5.1.14 ( Revision: $
)
jdbc driver major version=5
jdbc driver minor version=1
[INFO] [surefire:test
{execution: default-test}]
[INFO] Surefire report directory: C:\Project\full\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mycompany.webapp.listener.StartupListenerTest
DEBUG [main] LookupDaoHibernate.getRoles(38) | Retrieving all role names...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.309 sec
Running com.mycompany.webapp.action.PasswordHintActionTest
WARN [main] PasswordHintAction.execute(37) | Username not specified, notifying user that it's a required field.
WARN [main] PasswordHintAction.execute(74) | user 'UNKNOWN123' not found...
DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: -2
WARN [main] PasswordHintAction.execute(74) | user 'manager' not found...
DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: -2
WARN [main] PasswordHintAction.execute(74) | user 'manager' not found...
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.745 sec
Running com.mycompany.webapp.action.SignupActionTest
DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: null
DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: null
WARN [main] JDBCExceptionReporter.logExceptions(233) | SQL Error: 1062, SQLState: 23000
ERROR [main] JDBCExceptionReporter.logExceptions(234) | Duplicate entry 'self-registered@raibledesigns.com' for key 'email'
WARN [main] UserManagerImpl.saveUser(96) | could not insert: [org.appfuse.model.User]; SQL [insert into app_user (account_expired, account_locked, address, city, country, postal_code, province, credentials_expired, email, account_enabled, f
irst_name, last_name, password, password_hint, phone_number, username, version, website) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationExcep
tion: could not insert: [org.appfuse.model.User]
WARN [main] SignupAction.save(83) | User 'self-registered' already exists!
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.409 sec
Running com.mycompany.webapp.filter.LocaleFilterTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 sec
Running com.mycompany.webapp.action.UserActionTest
DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: -1
DEBUG [main] UserDaoHibernate.saveUser(49) | user's id: -1
WARN [main] JDBCExceptionReporter.logExceptions(233) | SQL Error: 1062, SQLState: 23000
ERROR [main] JDBCExceptionReporter.logExceptions(234) | Duplicate entry 'matt@raibledesigns.com' for key 'email'
ERROR [main] AbstractFlushingEventListener.performExecutions(324) | Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not update: org.appfuse.model.User#-1
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2612)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2494)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2821)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:113)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.springframework.orm.hibernate3.HibernateTemplate$28.doInHibernate(HibernateTemplate.java:883)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:881)
at org.appfuse.dao.hibernate.UserDaoHibernate.saveUser(UserDaoHibernate.java:53)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy45.saveUser(Unknown Source)
at org.appfuse.service.impl.UserManagerImpl.saveUser(UserManagerImpl.java:93)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:50)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy49.saveUser(Unknown Source)
at com.mycompany.webapp.action.UserAction.save(UserAction.java:179)
at com.mycompany.webapp.action.UserActionTest.testSaveConflictingUser(UserActionTest.java:78)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'matt@raibledesigns.com' for key 'email'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2407)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2325)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2310)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2594)
... 81 more
WARN [main] UserManagerImpl.saveUser(96) | could not update: org.appfuse.model.User#-1; SQL [update app_user set account_expired=?, account_locked=?, address=?, city=?, country=?, postal_code=?, province=?, credentials_expired=?, email=?,
account_enabled=?, first_name=?, last_name=?, password=?, password_hint=?, phone_number=?, username=?, version=?, website=? where id=? and version=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationExcept
ion: could not update: org.appfuse.model.User#-1
DEBUG [main] UserManagerImpl.removeUser(109) | removing user: -2
Tests run: 7, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.949 sec <<< FAILURE!
Results :
Tests in error:
testSearch(com.mycompany.webapp.action.UserActionTest)
Tests run: 22, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to C:\Project\full\target\surefire-reports for the individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25 seconds
[INFO] Finished at: Fri Feb 03 09:26:01 EST 2012
[INFO] Final Memory: 45M/109M
[INFO] ------------------------------------------------------------------------
C:\Project\full>