Attachments module bug/release

@mksd and others…

After this recent commit to the Attachments module, it won’t start up running against Platform 2.1, we are seeing the following error:

This is a blocker for our build pipeline, because there has’t been a release of the attachments module since we made the changes to make it 2.1 compatible. This was an oversight on my part… I should have done a release soon after doing that change so we don’t have to depend on the snapshot…

So I just did an emergency release based on the commit just prior to this, and then upgrade the version to 2.1.0-SNAPSHOT… hopefully this is okay with everyone…

Take care, Mark

Can you point me to the error message though? As this commit was done during GSoC we have a little more time to investigate and fix this.

Ack, sorry @mksd, I forgot to actually include the error message:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attachments.AttachmentsService' defined 
in URL [jar:file:/home/tomcat7/.OpenMRS/.openmrs-lib-cache/attachments/lib/attachments-api-2.0.0-SNAPSHOT.jar!/moduleApplication
Context.xml]: Cannot create inner bean 'org.openmrs.module.attachments.AttachmentsServiceImpl#6d3f37f' of type [org.openmrs.modu
le.attachments.AttachmentsServiceImpl] while setting bean property 'target'; nested exception is org.springframework.beans.facto
ry.BeanCreationException: Error creating bean with name 'org.openmrs.module.attachments.AttachmentsServiceImpl#6d3f37f': Injecti
on of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not auto
wire field: private org.openmrs.module.attachments.AttachmentsContext org.openmrs.module.attachments.AttachmentsServiceImpl.ctx;
 nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'attachments.Attachm
entsContext': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce
ption: Could not autowire field: protected org.openmrs.module.attachments.AttachmentsService org.openmrs.module.attachments.Atta
chmentsContext.attachmentsService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No quali
fying bean of type [org.openmrs.module.attachments.AttachmentsService] found for dependency: expected at least 1 bean which qual
ifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowire
d(required=true)}
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.ja
va:313)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueReso
lver.java:122)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapa
bleBeanFactory.java:1469)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBean
Factory.java:1214)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBean
Factory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFa
ctory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java
:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFact
ory.java:743)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationCon
text.java:757)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at org.openmrs.module.ModuleUtil.refreshApplicationContext(ModuleUtil.java:894)
	at org.openmrs.module.web.WebModuleUtil.refreshWAC(WebModuleUtil.java:866)
	at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:656)
	at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:635)
	at org.openmrs.web.Listener.startOpenmrs(Listener.java:266)
	at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.openmrs.module.attachment
s.AttachmentsServiceImpl#6d3f37f': Injection of autowired dependencies failed; nested exception is org.springframework.beans.fac
tory.BeanCreationException: Could not autowire field: private org.openmrs.module.attachments.AttachmentsContext org.openmrs.modu
le.attachments.AttachmentsServiceImpl.ctx; nested exception is org.springframework.beans.factory.BeanCreationException: Error cr
eating bean with name 'attachments.AttachmentsContext': Injection of autowired dependencies failed; nested exception is org.spri
ngframework.beans.factory.BeanCreationException: Could not autowire field: protected org.openmrs.module.attachments.AttachmentsS
ervice org.openmrs.module.attachments.AttachmentsContext.attachmentsService; nested exception is org.springframework.beans.facto
ry.NoSuchBeanDefinitionException: No qualifying bean of type [org.openmrs.module.attachments.AttachmentsService] found for depen
dency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springf
ramework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(Autowired
AnnotationBeanPostProcessor.java:334)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBean
Factory.java:1202)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBean
Factory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFa
ctory.java:476)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.ja
va:299)
	... 18 more

That’s at runtime correct?

Yeah, at server startup

Assuming that you are sure that the commit in question is the culprit, I would tend to be suspicious of this addition. It’s kind of the only thing that relied on autowiring a bean.

@ridmal could you look into that on a fresh Ref App 2.8.0?

@mogoodrich I don’t really understand though, you did a release after the breaking commit, how did this help you?

@mksd I cheated a bit… since this was the most recent commit, I did a branch off the commit previous to that one and did the 2.0.0 release manually, then merged it back into the main line and then incremented to 2.1.0-SNAPSHOT.

Incidentally @cintiadr this is an example of when it’s nice to be able to do a release manually (though, yes, I could have done the same thing by reverting the problem commit, doing the release, and then adding the commit back in).

Take care, Mark

1 Like

If that becomes a common usecase, we could change the release script to allow any commit to be ‘releasable’. Right now, it will fail if it’s not the last commit in master, but that’s something we could address in the future.

A post was split to a new topic: Attachmments: Error 415 (Unsupported Media Type)