AnsweredAssumed Answered

database constraint violation

Question asked by jian1505 on May 7, 2008
Hi all,

my application require that when I create a user, he is created with role consumer on his home space. I work with the web client.
I managed to do this by customizing authentication-services-context.xml changing from "all" to "consumer" the value of the property:

        <property name="ownerPemissionsToSetOnCreate">
            <set>
                <value>Consumer</value>
            </set>
        </property>
        <property name="userPemissions">
            <set>
                <value>Consumer</value>
            </set>
        </property>

for the bean userHomesHomeFolderProvider, and then modifying the classes CreateUserWizard and NewUserWizard to assign consumer permission for the user.

Now, my problem is that if I do so, when I try to delete the user I get this error:

A system error happened during the operation: could not delete: [org.alfresco.repo.domain.hibernate.DbAuthorityImpl#4]; nested exception is org.hibernate.exception.ConstraintViolationException: could not delete: [org.alfresco.repo.domain.hibernate.DbAuthorityImpl#4]

Same error if I roll back all the changes and create the user with "all" permissions, then I manually remove the "all" permission and set the "consumer" role. I don't now if this can help, in this case I noticed that the database entry for the role I just removed, in the table "alf_access_control_entry" doesn't gets removed…

Is there anyone that could tell me what is wrong or point me in the right directions to solve this? I can't understand if this is a bug, a database problem or else… below I post the stack trace of the exception thrown…
Many thanks,
Gianmarco

the stack trace of the exception is:

User:admin ERROR [ui.common.Utils] A system error happened during the operation: could not delete: [org.alfresco.repo.domain.hibernate.DbAuthorityImpl#4]; nested exception is org.hibernate.exception.ConstraintViolationException: could not delete: [org.alfresco.repo.domain.hibernate.DbAuthorityImpl#4]
org.springframework.dao.DataIntegrityViolationException: could not delete: [org.alfresco.repo.domain.hibernate.DbAuthorityImpl#4]; nested exception is org.hibernate.exception.ConstraintViolationException: could not delete: [org.alfresco.repo.domain.hibernate.DbAuthorityImpl#4]
Caused by: org.hibernate.exception.ConstraintViolationException: could not delete: [org.alfresco.repo.domain.hibernate.DbAuthorityImpl#4]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2491)
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2647)
        at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:74)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:329)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:312)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:562)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:654)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:624)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:307)
        at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:431)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:250)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:166)
        at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:127)
        at org.alfresco.web.bean.dialog.DialogManager.finish(DialogManager.java:534)
        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:585)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
        at javax.faces.component.UICommand.broadcast(UICommand.java:109)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
        at java.lang.Thread.run(Thread.java:595)
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`alfresco/alf_access_control_entry`, CONSTRAINT `fk_alf_ace_auth` FOREIGN KEY (`authority_id`) REFERENCES `alf_authority` (`id`))
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
        at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
        at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2473)
        … 49 more

Outcomes