org.openmrs.api.APIException: Unable to set module service:

Investigated this well but not yet sure why openmrs is failing to set my module’s service: Error message:

http://pastebin.com/HCLUBb2Q

Source-code: https://github.com/rwanda-rbc-emr/openmrs-module-quarterlyreporting

The moduleApplicationContext.xml file here contains this failing bean;

<bean parent="serviceContext">
		<property name="moduleService">
			<list>
				<value>org.openmrs.module.quarterlyreporting.service.QuarterlyReportingService
				</value>
				<bean
					class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
					<property name="transactionManager">
						<ref bean="transactionManager" />
					</property>
					<property name="target">
						<bean
							class="org.openmrs.module.quarterlyreporting.serviceimpl.QuarterlyReportingServiceImpl">
							<property name="quarterlyreportingDAO">
								<bean
									class="org.openmrs.module.quarterlyreporting.db.daoimpl.QuarterlyReportingDAOImpl">
									<property name="sessionFactory">
										<ref bean="sessionFactory" />
									</property>
								</bean>
							</property>
						</bean>
					</property>
					<property name="preInterceptors">
						<list>
							<ref bean="authorizationInterceptor" />
						</list>
					</property>
					<property name="transactionAttributeSource">
						<bean
							class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource" />
					</property>
				</bean>
			</list>
		</property>
	</bean>

This is slightly related to but different from:

Seems to result from ClassNotFoundException being caught at:

Doing further investigation

So, after debugging openmrs-core api, i could understand where the issue was, the service set under values tag above contained empty spaces/tabs at its end which caused

to fail as a class not found issue.

A quick fix in my module is removing all spaces under values tag which means changing.

<value>org.openmrs.module.quarterlyreporting.service.QuarterlyReportingService
				</value>

to

<value>org.openmrs.module.quarterlyreporting.service.QuarterlyReportingService</value>

I suggest that openmrs-core fixes this by invoking trim() onto the Service classString at:

We can ticket this as an intro task to quickly be worked upon since any mis-added space(s) as in my case currently may help the dev to spend more time investigating such as simple issue

1 Like

i leave this for the newbies to file a ticket and work on it

I disagree about creating a ticket for this.

There are hundreds or thousands of places in our spring xml files where we specify a <value> and we don’t trim any of these. Why would we have API support for trimming just one of them?

3 Likes

thanks @k_joseph you saved me from debugging duty! my hero of the day :tada: I think the formatter should just not format the xml in this way.

2 Likes