Upgrading this to dev list. We're working on a custom cohort definition in the reporting framework for patients having drug orders. We added a configuration property to the definition so that we can specify a list of concepts to describe all ARV drugs:
@ConfigurationProperty(required=false) private List<Concept> masterDrugSets; but when we try and save the definition we get a LazyInitializationException : *An Internal Error has Occurred* *org.hibernate.LazyInitializationException* *failed to lazily initialize a collection of role: org.openmrs.Concept.names, no session or session was closed* More details in emails below including complete exception. We'll try using a PersonAttributeCohortDefinition and see if the same thing happens as suggested. On 10 May 2012 16:16, Michael Seaton <msea...@pih.org> wrote: > ** > Hi Rowan, > > I would use the dev list for this kind of question. Here is what I would > guess is happening: > > The way the RequiredDataAdvice works in OpenMRS is that it AOPs around any > method in a service that implements OpenmrsService and which is like > "save*(obj)" and makes sure any required data that can be automatically > handled (createdBy, dateCreated, changedBy, dateChanged, etc.) are set. It > also recurses over any property which is a Collection containing objects > that implement OpenmrsObject, and applies the same processing to these > objects. So that is what is happening here - by virtue of saving the > CohortDefinition, OpenMRS core is saving all underlying Concepts configured > on this CohortDefinition as well. > > Now, there are a number of issues here: > > * I would think we do not want this behavior in general for this type of > Object - eg. we do not want saving Definitions in the reporting module to > perform a save on any associated data. However, I don't believe there is > any way to turn this off, particularly in 1.6.x. I think Mark ran into > this recently though in another context, and may have applied some patches, > so I'm copying him here to comment. *@Mark?* > > * Even if we can live with this behavior the way it is currently working, > this stack trace is a problem. I don't know why it is happening. I'm in > Malawi with not great connectivity at the moment, but you might want to > look through JIRA in the reporting module and/or trunk to see if a similar > error message has previously been reported and resolved that might indicate > that updating to 1.6.x or the reporting module would help. That being > said, the CodedObsCohortDefinition and the PersonAttributeCohortDefinition > both use a List<Concept> property, and don't believe there are any open > tickets around these. Can you try configuring one of these in the UI and > saving it with multiple Concepts and see if you get this stack trace when > saving? Could you try upgrading a dev/test environment to 1.6.x and see if > that helps as well? Can you reproduce your bug in a unit test? > > I would hit the dev list to see if Ben or anyone else remembers any > specific fixes or other details around this error. If all else fails, > since you are writing your reports in code and not via the UI, you could > change your configuration property from a List<Concept> masterDrugSets to a > List<Integer> masterDrugSetConceptIds and this would alleviate the > problem... > > Mike > > > > > On 05/09/2012 10:39 AM, Rowan Seymour wrote: > > Hi guys > > So Mariam and I have been trying to add that functionality to our ARV > reports that we discussed before - that is being able to check that a > patient's regimen is *EXACTLY *the specified regimen and that they are > not taking additional ARVs. We can't modify the PatientSetService as this > has to work with OpenMRS 1.6.x. So I added two new properties to our > DrugOrderCohortDefinition class (in bold): > > @ConfigurationProperty(required=false) > private List<Drug> drugList; > @ConfigurationProperty(required=false) > private List<Concept> drugSets; > @ConfigurationProperty(required=false) > private GroupMethod anyOrAll; > > *@ConfigurationProperty(required=false)* > *private Boolean exactlyAll;* > * > * > *@ConfigurationProperty(required=false)* > *private List<Concept> masterDrugSets;* > > with setters and getters, and then created our own service methods for > checking drug orders against a master list of drugs which in our case will > be the list of all ARV drugs. However we're now getting an exception > whenever we save the cohort definition, i.e. > > DrugOrderCohortDefinition onRegimen = new DrugOrderCohortDefinition(); > onRegimen.setName("patient on........" + regimenName + "regimen"); > onRegimen.addParameter(new Parameter("startDate","Start of Period", > Date.class)); > onRegimen.addParameter(new Parameter("endDate","End of Period", > Date.class)); > onRegimen.setDrugList(drugs); > onRegimen.setAnyOrAll(GroupMethod.ALL); > *onRegimen.addMasterDrugSet(Context.getConceptService().getConcept(1085)); > // All ARVs* > *onRegimen.setExactlyAll(true);* > h.replaceCohortDefinition(onRegimen); > > The exception is in email below from Mariam. Am hoping you can point us > in the right direction. Thanks! > > On 9 May 2012 15:39, Mariam N. <nmary...@gmail.com> wrote: > >> >> An Internal Error has Occurred * >> org.hibernate.LazyInitializationException* >> >> failed to lazily initialize a collection of role: org.openmrs.Concept.names, >> no session or session was closed >> >> >> >> Consult the help document <http://localhost:8080/openmrs/help.htm>. >> Contact your friendly neighborhood administrator if it cannot be >> resolved. >> >> Hide stack >> trace<http://localhost:8080/openmrs/module/rwandamohreports/register_HIVCareAndARTReport.form#> >> >> >> org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358) >> >> org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350) >> >> org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343) >> >> org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) >> org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163) >> *org.openmrs.Concept.getNames(Concept.java:1028)* >> *org.openmrs.Concept.getNames(Concept.java:1012)* >> * >> org.openmrs.api.handler.ConceptSaveHandler.handle(ConceptSaveHandler.java:46) >> * >> * >> org.openmrs.api.handler.ConceptSaveHandler.handle(ConceptSaveHandler.java:1) >> * >> * >> org.openmrs.aop.RequiredDataAdvice.recursivelyHandle(RequiredDataAdvice.java:217) >> * >> * >> org.openmrs.aop.RequiredDataAdvice.recursivelyHandle(RequiredDataAdvice.java:234) >> * >> * >> org.openmrs.aop.RequiredDataAdvice.recursivelyHandle(RequiredDataAdvice.java:180) >> * >> *org.openmrs.aop.RequiredDataAdvice.before(RequiredDataAdvice.java:130)* >> >> org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:49) >> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) >> >> org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50) >> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) >> >> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) >> $Proxy8432.saveDefinition(Unknown Source) >> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) >> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) >> java.lang.reflect.Method.invoke(Unknown Source) >> >> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) >> >> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) >> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) >> >> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) >> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) >> >> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) >> $Proxy8432.saveDefinition(Unknown Source) >> * >> org.openmrs.module.rwandamohreports.reporting.Helper.replaceCohortDefinition(Helper.java:172) >> * >> * >> org.openmrs.module.rwandamohreports.reporting.SetupHIVCareAndARTReport.createReportDefinition(SetupHIVCareAndARTReport.java:874) >> * >> * >> org.openmrs.module.rwandamohreports.reporting.SetupHIVCareAndARTReport.setup(SetupHIVCareAndARTReport.java:66) >> * >> * >> org.openmrs.module.rwandamohreports.web.controller.RwandaSetupReportsFormController.registerHIVCareAndARTReport(RwandaSetupReportsFormController.java:74) >> * >> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) >> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) >> java.lang.reflect.Method.invoke(Unknown Source) >> >> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:421) >> >> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:136) >> >> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:326) >> >> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:313) >> >> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) >> >> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807) >> >> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) >> >> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) >> javax.servlet.http.HttpServlet.service(HttpServlet.java:617) >> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> * >> org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:76) >> * >> * >> org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:58) >> * >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> * >> org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:112) >> * >> >> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> >> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) >> >> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> *org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:82)* >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> *org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:82)* >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> *org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:82)* >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> >> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) >> >> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) >> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) >> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) >> >> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) >> >> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) >> >> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) >> >> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >> >> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) >> >> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) >> >> org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859) >> >> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574) >> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1527) >> java.lang.Thread.run(Unknown Source) >> >> >> OpenMRS Version: 1.6.3 dev Build 18591 >> >> -- >> >> *Dr Rowan Seymour** >> Partners In Health, Rwanda* >> Tel: +250783835665 >> >> >> >> -- *Dr Rowan Seymour** Partners In Health, Rwanda* Tel: +250783835665 _________________________________________ To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to lists...@listserv.iupui.edu with "SIGNOFF openmrs-devel-l" in the body (not the subject) of your e-mail. [mailto:lists...@listserv.iupui.edu?body=SIGNOFF%20openmrs-devel-l]