Unable to uninstall Stock module

Hello,

I’ve setup an axelor project, with all ABS modules, and now I was trying to remove some unnecessary modules… From the Administration -> Module Management I’ve uninstalled the “axelor stock” module. Restarting the server it throws me the follow error:

[localhost-startStop-1] INFO com.axelor.meta.loader.ModuleManager - easypbx-crm
2017-05-20 18:17:14,139 [localhost-startStop-1] DEBUG com.axelor.meta.loader.ViewLoader - Loading view: meta-sequence-grid
2017-05-20 18:17:16,508 [localhost-startStop-1] DEBUG com.axelor.meta.loader.ViewLoader - Loading view: meta-sequence-form
2017-05-20 18:17:16,595 [localhost-startStop-1] DEBUG com.axelor.meta.loader.ViewLoader - Creating default views: /tmp/axelor/generated/views/MetaSequence.xml
2017-05-20 18:17:25,017 [localhost-startStop-1] INFO com.axelor.meta.loader.ModuleManager - Uninstall module: axelor-stock
2017-05-20 18:17:26,157 [localhost-startStop-1] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: update or delete on table “meta_menu” violates foreign key constraint “fk_jk6vvh0bx8cx8o1tjacx6dtcn” on table “meta_menu”
Dettaglio: Key (id)=(167) is still referenced from table “meta_menu”.
2017-05-20 18:17:26,286 [localhost-startStop-1] ERROR com.axelor.web.servlet.InitServlet - org.hibernate.exception.ConstraintViolationException: could not execute statement
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:316)
at com.axelor.db.Query.count(Query.java:298)
at com.axelor.db.Query.remove(Query.java:382)
at com.axelor.meta.loader.ModuleManager.uninstall(ModuleManager.java:235)
at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:70)
at com.axelor.meta.loader.ModuleManager$1.run(ModuleManager.java:131)
at com.axelor.auth.AuditableRunner$1.call(AuditableRunner.java:58)
at com.axelor.auth.AuditableRunner$1.call(AuditableRunner.java:55)
at com.axelor.auth.AuditableRunner.run(AuditableRunner.java:90)
at com.axelor.auth.AuditableRunner.run(AuditableRunner.java:55)
at com.axelor.meta.loader.ModuleManager.initialize(ModuleManager.java:140)
at com.axelor.web.servlet.InitServlet.init(InitServlet.java:50)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:121)
at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82)
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:103)
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:220)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4841)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:129)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:189)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3358)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3558)
at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:102)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:395)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:387)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:310)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:349)
at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:67)
at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1166)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1223)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:287)
… 28 more
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table “meta_menu” violates foreign key constraint “fk_jk6vvh0bx8cx8o1tjacx6dtcn” on table “meta_menu”
Dettaglio: Key (id)=(167) is still referenced from table “meta_menu”.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:147)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:186)

And module is not uninstalled. Any idea?

Thanks

As workaround, I’ve manually deleted all meta_menu entries referencing the “axelor-stock” module from the db (postgresql). Let me know if there is a more “user-friendly” tip to do it

Hi,
To uninstall any module you have to uninstall its dependent modules first. Uninstall modules in dependent hierarchy one by one (uninstall and restart server) only.