Marek Schmidt created JBSEAM-5070:
-------------------------------------
Summary: seam-gen identity-management creating a new user fails with
org.hibernate.exception.ConstraintViolationException: Duplicate entry '1' for key
1
Key: JBSEAM-5070
URL:
https://issues.jboss.org/browse/JBSEAM-5070
Project: Seam 2
Issue Type: Bug
Affects Versions: 2.3.0.Final
Environment: AS 7.1.1, MySQL 5.1
Reporter: Marek Schmidt
Assignee: Marek Novotny
Fix For: 2.3.1.CR1
Attempting to create a new user in a seam-gen generated project with identity-management
fails with javax.persistence.PersistenceException:
org.hibernate.exception.ConstraintViolationException: Duplicate entry '1' for key
1.
Problem seems to be that the generated resources/import-dev.sql contains the initial
entries with ids 1,2,3, ..., which conflicts with the attempted generated ids.
{noformat}
13:07:58,079 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper]
(http--127.0.0.1-8080-4) SQL Error: 1062, SQLState: 23000
13:07:58,080 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper]
(http--127.0.0.1-8080-4) Duplicate entry '1' for key 1
13:07:58,088 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle]
(http--127.0.0.1-8080-4) #{userAction.save}: javax.persistence.PersistenceException:
org.hibernate.exception.ConstraintViolationException: Duplicate entry '1' for key
1: javax.faces.FacesException: #{userAction.save}: javax.persistence.PersistenceException:
org.hibernate.exception.ConstraintViolationException: Duplicate entry '1' for key
1
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397)
[jbossweb-7.0.13.Final.jar:]
at
org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
[jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.13.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_35]
Caused by: javax.faces.el.EvaluationException: javax.persistence.PersistenceException:
org.hibernate.exception.ConstraintViolationException: Duplicate entry '1' for key
1
at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
[jsf-impl-2.1.7-jbossorg-2.jar:]
... 38 more
Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.ConstraintViolationException: Duplicate entry '1' for key
1
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361)
[hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289)
[hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:313)
[hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at
org.jboss.seam.security.management.JpaIdentityStore.lookupUser(JpaIdentityStore.java:863)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at
org.jboss.seam.security.management.JpaIdentityStore.grantRole(JpaIdentityStore.java:307)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.security.management.IdentityManager.grantRole(IdentityManager.java:136)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.security.management.action.UserAction.saveNewUser(UserAction.java:83)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.security.management.action.UserAction.save(UserAction.java:61)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_35]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[rt.jar:1.6.0_35]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[rt.jar:1.6.0_35]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_35]
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at
org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:65)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:186)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:104)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at
org.jboss.seam.security.management.action.UserAction_$$_javassist_seam_3.save(UserAction_$$_javassist_seam_3.java)
[jboss-seam.jar:2.3.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_35]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[rt.jar:1.6.0_35]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[rt.jar:1.6.0_35]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_35]
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
[jboss-el.jar:1.0_02.CR6]
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
[jboss-el.jar:1.0_02.CR6]
at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
[jboss-el.jar:1.0_02.CR6]
at org.jboss.el.parser.AstValue.invoke(AstValue.java:96) [jboss-el.jar:1.0_02.CR6]
at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
[jboss-el.jar:1.0_02.CR6]
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
[jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
... 39 more
Caused by: org.hibernate.exception.ConstraintViolationException: Duplicate entry
'1' for key 1
at
org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:74)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at $Proxy81.executeUpdate(Unknown Source) at
org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:56)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2849)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3290)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:80)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:272)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:264)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:186)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at
org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:59)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1053)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1108)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:280)
[hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
... 74 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '1' for key 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[rt.jar:1.6.0_35]
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[rt.jar:1.6.0_35]
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[rt.jar:1.6.0_35]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_35]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at
org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_35]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[rt.jar:1.6.0_35]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[rt.jar:1.6.0_35]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_35]
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
[hibernate-core-4.0.1.Final.jar:4.0.1.Final]
... 89 more
{noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira