Unsatisfied dependency exception whilst running reports.

Hi there,

We’re using an EndTB release of Bahmni (I think version 0.89?) and are experiencing issues when running reports.

Whenever we run reports, we’re shown a ‘There was an unexpected issue on the server. Please try again. Error in scheduling report’ error message, and the reports fail to download. I’ve had a look at the JS console in Chrome, and it states that the request to schedule returns a 500 error.

The GET request is as follows: https://bahmni/bahmnireports/schedule?name=<REDACTED>-New%20drug%20enrollment%20(Custom%20Excel)&startDate=2016-01-01&endDate=2016-12-31&responseType=application/vnd.ms-excel-custom&paperSize=A3&appName=reports&userName=<REDACTED>&macroTemplateLocation=/var/www/bahmni_config/openmrs/apps/reports/macroTemplates/DrugOrderTemplate.xls

The response shows that a org.springframework.beans.factory.UnsatisfiedDependencyException exception is thrown, with the following message: Unsatisfied dependency expressed through field 'scheduler': Error creating bean with name 'scheduler' defined in class path resource [org/bahmni/reports/scheduler/QuartzConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.quartz.SchedulerFactoryBean]: Factory method 'scheduler' threw exception; nested exception is java.lang.RuntimeException: Cannot start scheduler:-; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduler' defined in class path resource [org/bahmni/reports/scheduler/QuartzConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.quartz.SchedulerFactoryBean]: Factory method 'scheduler' threw exception; nested exception is java.lang.RuntimeException: Cannot start scheduler:

The stack trace is as follows:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘reportsScheduler’: Unsatisfied dependency expressed through field ‘scheduler’: Error creating bean with name ‘scheduler’ defined in class path resource [org/bahmni/reports/scheduler/QuartzConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.quartz.SchedulerFactoryBean]: Factory method ‘scheduler’ threw exception; nested exception is java.lang.RuntimeException: Cannot start scheduler:-; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘scheduler’ defined in class path resource [org/bahmni/reports/scheduler/QuartzConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.quartz.SchedulerFactoryBean]: Factory method ‘scheduler’ threw exception; nested exception is java.lang.RuntimeException: Cannot start scheduler:- org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569) org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:540) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:534) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) – Redacted due to space limitations –

I can’t add the whole stacktrace to this post, so I’ve added it to a pastebin: https://pastebin.com/Bygrvfh5

I’ve tried restarting the services in case it was just some random bug, but it hasn’t made any difference.

Is there anything I can do to resolve this? I don’t think we’ll be able to upgrade our Bahmni installation at this point.

Please let me know if there’s anything else I can provide.

Thanks in advance,

Kind Regards,

Andrew

Bump. Does anyone have any ideas on what I can do to resolve this?

Any assistance would be greatly appreciated. :slight_smile:

Thanks, Andrew

@judeniroshan Do you have any idea about this Report problem?

I haven’t worked with Bahmni distribution. :neutral_face:But as for the exception trace, it is clear that some bean configuration has messed up. Please check with this particular class name bean has properly defined in the server module.

Error creating bean with name 'scheduler' defined in class path resource [org/bahmni/reports/scheduler/QuartzConfiguration.class]

Technically speaking, it means, a “Scheduler” instance is not being injected (by Spring) to ReportScheduler! Now, this “Scheudler” instance should be automatically created by the creation of “SchedulerFactoryBean” at the very startup.

Can you stop the service, backup the old log file (/var/log/bahmni-reports/bahmni-reports.log) and start it again and pull up the entire log in a gist?

service bahmni-reports restart

Hi All,

Thanks so much for your responses, it is greatly appreciated.

Please find the gist here: https://gist.github.com/xtrasimplicity/6e88667de3d868f9006781d008d28a70

Looking at the logs, it looks like it is trying to access an SQL database named bahmni_reports, and the only database that exists on the server is openmrs, so it looks like there was an issue during installation and the database wasn’t created.

Given this site is in production, is there any recommended way to recreate just this database? Or is it best to bring the site offline, make a backup of the openmrs database, re-install and restore the SQL backup?

Thanks!

Andrew

The database just keeps the scheduled report info.

Can you check the inventory file? (I am assuming that you are using the bahmni installer program, and not directly installing rpms)

/etc/bahmni-installer/local

Check whether there are any entry in the “bahmni-reports-db”. something like

[bahmni-reports-db] 127.0.0.1

I am guessing the entry is empty, and possibly explains why the database was not created. If this is so, then you can modify the inventory file (local) and re run the bahmni installer program.

Now considering its production site, obviously you should take necessary precautions @senthilrajar, can you please comment ?

I can think of

  1. Backup - all dbs, configs, logs, inventory and setup config files ( /etc/bahmni-installer/local, /etc/bahmni-installer/setup.yml). any additional modules etc.
  2. Do it only after work hours
  3. resintall reports

bahmni -i local --only bahmni-reports install

The above should install only the reports. @senthilrajar will this reinstall EMR component as well? Also, when was the –only option introduced, is this available for v0.88?

  1. Try this out on your local setup first.
  2. If you active-passive setup in production, try this on passive first (remember to setup database sync once you install on active as well) - you can control this via the inventory and setup.yml file.

More info on advance installation here: https://bahmni.atlassian.net/wiki/pages/viewpage.action?pageId=35291242

Let us know if you need more help.

1 Like

Yeah, the inventory file has the database server listed under the bahmni-reports-db group.

We do have an Active/Passive setup, but it doesn’t look like uploaded files (i.e. for dcm4chee) are synchronised between the active and passive web servers, so I’m thinking it might be easiest to set up a new VM (alongside this one), install Bahmni from scratch all on the one VM, put the production site in maintenance mode and then restore the production SQL backup to the new VM. I’ll need to check with my colleagues to see whether they’re comfortable with me switching from Active/Passive clustering to a single VM, first, though.

I’ll keep you updated.

Thanks once again!

Andrew

if I am right, you don’t use Dcm4Chee (PACS) for endTB. If you just backup the listed items - dbs, configs, logs, inventory and setup config files and patient images directories etc, you should be ok to run upgrade or only rerun bahmni-reports installation.

Bahmni installer will keep all your settings and data intact during a reinstall and upgrade, but backups are

You can take the passive box, restore dbs and other files and rerun the installations. This will mean that the active is still usable by users.

Then make passive as active - change IP address, name controller changes (if you are using any). So now the passive becomes the active.

Then run upgrade on old active, if everything works, set this as passive - you will have to reset the position markers for the database syncs though.

Alternatively, your single VM is also fine, but you wouldn’t have automatic data replication in the passive. or redundancy in your setup.

NOTE: One of our implementations also use a blue-green deployment. I don’t know if makes sense for you to consider for future.

Thanks for that. I’m not 100% familiar with how this all works, so I appreciate the clarification re: Dcm4Chee. :slight_smile:

I’ve been advised that we’re having this report issue on some non-HA vagrant VMs, too, so I’m currently setting up a new test environment from scratch to see whether I can replicate it.

Thanks once again!

Andrew

Hi Angshuman,

I’ve just reinstalled Bahmni using bahmni -i remote install but it doesn’t appear to have made any diference. I have another idea which I’ll try and will report back once I’ve tested it out.

Any further feedback you can provide in the mean time would be greatly appreciated, however. :slight_smile:

Thanks once again!

Kind Regards,

Andrew

Hi Angshuman,

I’ve had some strange issues with running /usr/bin/bahmni-batch on Bahmni endTB 1.5.0 (Bahmni 0.85), and have ended up having to symlink /etc/bahmni-installer/bahmni.conf to /etc/bahmni-installer/bahmni-emr-installer.conf to allow the final installation step to complete. I have been able to reproduce this error numerous times on multiple freshly-installed Vagrant VMs.

When I follow the historical version of the instructions, without symlinking bahmni.conf to bahmni-emr-installer.conf, I get the following error:

[bahmni@bahmni01 root]$ /usr/bin/bahmni-batch 
/usr/bin/bahmni-batch: line 3: /etc/bahmni-installer/bahmni-emr-installer.conf: No such file or directory
Running bahmni-batch...

If I create the symlink, /usr/bin/bahmni-batch works, but OpenMRS freezes at:

01-09-2017 11:37:30 [INFO ] HibernateSessionFactoryBean - Building new Hibernate SessionFactory

I’ve uploaded a gist for this, here. It looks like it may be caused by an external dependency being updated, so I suppose upgrading to the latest version of endTB (or merging back into the Bahmni master branch, if the endTB branch has been merged) may resolve this?

If so, is it possible to restore endTB 1.5.0 SQL and patient data backups onto a fresh endTB 2.0 installation, or would I need to perform a manual upgrade from 1.5.0 to 1.5.1, and then to 2.0.3?

Would you like me to ask this in a new thread?

Thanks once again for all of your assistance so far.

Kind Regards,

Andrew

I was able to resolve this issue, by creating the bahmni_reports database and adding the structure from a freshly-deployed Bahmni 0.85 vagrant box.

Step by step, I did the following:

  • Retrieved my reports SQL credentials from /opt/bahmni-installer/bahmni-playbooks/group_vars/**INVENTORY_FILE**
  • SSH’d into the database server, logged into MySQL using these credentials: mysql -u reports_root_user -p
  • Created the bahmni_reports database, using: create database `bahmni_reports`
  • Exited the MySQL console, using exit
  • Pasted the SQL dump for the DB structure into a file, say, bahmni_reports_structure.sql.
  • Imported the dump into the bahmni_reports database: mysql -u reports_root_user -p bahmni_reports < bahmni_reports_structure.sql
  • Restarted bahmni-reports: sudo service bahmni-reports restart

This issue was also fairly helpful. :slight_smile: