An Internal Error has Occurred org.hibernate.exception.SQLGrammarException could not insert: [org.openmrs.module.department.Department]

Application Name: Reference Application, Bahmni

Question:

I have installed bahmni using vagrant on my windows system . The basic module developed on my openmrs system works fine on the bahmni’s. When i am dealing with module to save some data , it returns with the following error : http://pastebin.com/bSySv8jW

I think its a general problem. Hope, someone in bahmni would suggest me a solution as soon as possible.category.

The log under Stack Trace is as follows : : http://pastebin.com/jFniTTy3

Can you please add more details about what steps you took before this error came up? Which modules are you working on, and which version of Bahmni was running?

I have installed the bahmni cloning from https://github.com/Bahmni/bahmni-vagrant.git followed the intruction from https://bahmni.atlassian.net/wiki/display/BAH/Bahmni+Virtual+Box for my windows system.

I have trying out for department module as mentioned in http://en.flossmanuals.net/openmrs-developers-guide/hello-world-module/ .

And the module was working fine in my openmrs system but not while adding the module on the bahmni’s openmrs.

In the tutorial, there seems to be some liquibase.xml entry which helps create the table. The logs which you attached, do they fail while executing the liquibase command. Where did you add this module – /opt/bahmni/modules?

I have added the module from manage module link under Module section in the adminitration page of openmrs UI. (192.168.33.10/openmrs).

Can you please paste the complete /var/log/openmrs/openmrs.log file in pastebin?

Sorry for delay : Content of /var/log/openmrs/openmrs.log is pasted in : http://pastebin.com/Da8i1aKN

There seem to be too many errors in openmrs log, which don’t seem to be directly related to Bahmni:

This error says it found a placeholder file in modules folder. I guess we can ignore this / delete this.

16-05-2016 11:29:21 [ERROR] ModuleFactory - Error getting module object from file placeholder
org.openmrs.module.ModuleException: Module file does not have the correct '.omod' file extension Module: placeholder
    at org.openmrs.module.ModuleFileParser.<init>(ModuleFileParser.java:88)
    at org.openmrs.module.ModuleFactory.getModuleFromFile(ModuleFactory.java:528)
    at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:107)
    at org.openmrs.module.ModuleFactory.loadModules(ModuleFactory.java:186)
    at org.openmrs.module.ModuleFactory.loadModules(ModuleFactory.java:169)
    at org.openmrs.module.ModuleUtil.startup(ModuleUtil.java:76)
    at org.openmrs.api.context.Context.startup(Context.java:885)
    at org.openmrs.web.Listener.startOpenmrs(Listener.java:227)
    at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42)

This one says it is trying to start an ActiveMQ JMS Message broker. I have no idea which module requires this. Do you?

16-05-2016 11:30:56 [ERROR] BrokerService - Failed to start ActiveMQ JMS Message Broker. Reason: java.io.IOException: Invalid location: 1:11392824, : java.lang.NegativeArraySizeException
java.io.IOException: Invalid location: 1:11392824, : java.lang.NegativeArraySizeException
    at org.apache.kahadb.journal.DataFileAccessor.readRecord(DataFileAccessor.java:94)
    at org.apache.kahadb.journal.Journal.read(Journal.java:596)
    at org.apache.activemq.store.kahadb.MessageDatabase.load(MessageDatabase.java:786)
    at org.apache.activemq.store.kahadb.MessageDatabase.recoverProducerAudit(MessageDatabase.java:484)
    at org.apache.activemq.store.kahadb.MessageDatabase.recover(MessageDatabase.java:438)
    at org.apache.activemq.store.kahadb.MessageDatabase.open(MessageDatabase.java:315)
    at org.apache.activemq.store.kahadb.MessageDatabase.load(MessageDatabase.java:357)
    at org.apache.activemq.store.kahadb.MessageDatabase.doStart(MessageDatabase.java:222)
    at org.apache.activemq.store.kahadb.KahaDBStore.doStart(KahaDBStore.java:180)
    at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:53)
    at org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter.start(KahaDBPersistenceAdapter.java:186)
    at org.apache.activemq.broker.BrokerService.start(BrokerService.java:485)
    at org.apache.activemq.transport.vm.VMTransportFactory.doCompositeConnect(VMTransportFactory.java:123)
    at org.apache.activemq.transport.vm.VMTransportFactory.doConnect(VMTransportFactory.java:53)
    at org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.java:51)
    at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:80)
    at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:243)
    at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:258)
    at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:230)
    at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:178)
    at org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:342)
    at org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:288)
    at org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:225)
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
    at org.springframework.jms.core.JmsTemplate.access$0(JmsTemplate.java:1)
    at org.springframework.jms.core.JmsTemplate$JmsTemplateResourceFactory.createConnection(JmsTemplate.java:1031)
    at org.springframework.jms.connection.ConnectionFactoryUtils.doGetTransactionalSession(ConnectionFactoryUtils.java:297)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:453)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:534)
    at org.openmrs.event.EventEngine.doFireEvent(EventEngine.java:100)
    at org.openmrs.event.EventEngine.fireEvent(EventEngine.java:79)
    at org.openmrs.event.EventEngine.fireAction(EventEngine.java:65)
    at org.openmrs.event.Event.fireAction(Event.java:38)
    at org.openmrs.event.api.db.hibernate.HibernateEventInterceptor.afterTransactionCompletion(HibernateEventInterceptor.java:168)
    at org.openmrs.api.db.hibernate.ChainingInterceptor.afterTransactionCompletion(ChainingInterceptor.java:211)
    at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:605)
    at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:273)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:146)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:657)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at com.sun.proxy.$Proxy209.saveTask(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:121)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at com.sun.proxy.$Proxy210.saveTask(Unknown Source)
    at org.openmrs.scheduler.timer.TimerSchedulerTask.saveLastExecutionTime(TimerSchedulerTask.java:71)
    at org.openmrs.scheduler.timer.TimerSchedulerTask.execute(TimerSchedulerTask.java:95)
    at org.openmrs.api.context.Daemon$2.run(Daemon.java:130)

I just figured out the main error yet but as I deleted the department table and used the schema in the mysql database of my openMRS system and load that in the bahmni’s db. It started working fine then.

Thanks for your suggesstion @gsluthra to look into /var/log/openmrs/openmrs.log from which i realized there’s something wrong with department table.