I am trying to get REST API for my custom module and followed
https://wiki.openmrs.org/display/docs/Adding+a+Web+Service+Step+by+Step+Guide+for+Module+Developers
I followed following steps
> Mentioned webservices.rest and webservices.rest-omod-common dependencies in pom.xml
to be precise ..
--> added extends MainResourceController to class definition of existing controller
added import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController;
--> added a new variable
public static final String BpReading_REST_NAMESPACE = "/bpr";
--> added a new method
@RequestMapping("/rest/" + RestConstants.VERSION_1 + BpReadingModuleManageController.BpReading_REST_NAMESPACE)
public String getNamespace() {
String link = "/rest/" + RestConstants.VERSION_1 + BpReadingModuleManageController.BpReading_REST_NAMESPACE;
System.out.println("Using This Namespace for BPReading Module : "+link);
return RestConstants.VERSION_1 + BpReadingModuleManageController.BpReading_REST_NAMESPACE;
}
The module shows success on "mvn clean install"
I then uploaded generated omod in Admin Section of OpenMRS 1.9.7 , on which it gave following error for why it was not able to start it
Unable to refresh the WebApplicationContext
Error creating bean with name 'messageSourceServiceTarget' defined in class path resource [applicationContext-service.xml]: Cannot resolve reference to bean 'mutableResourceBundleMessageSource' while setting bean property 'activeMessageSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mutableResourceBundleMessageSource' defined in class path resource [applicationContext-service.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor#0' defined in class path resource [applicationContext-service.xml]: Cannot resolve reference to bean 'transactionInterceptor' while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionInterceptor' defined in class path resource [applicationContext-service.xml]: Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext-service.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public java.util.Map org.openmrs.api.db.hibernate.HibernateSessionFactoryBean.interceptors; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.openmrs.module.bpReadingModule.web.controller.BpReadingModuleManageController] for bean with name 'bpReadingModuleManageController' defined in URL [jar:file:/tmp/1401980215608.openmrs-lib-cache/bpReadingModule/bpReadingModule.jar!/org/openmrs/module/bpReadingModule/web/controller/BpReadingModuleManageController.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/openmrs/module/webservices/rest/web/v1_0/controller/MainResourceController
It shows me no error in eclipse in my controller class where I have written "extends MainResourceController" in my controller class and also on doing a control click it takes me to its implementation class present in Rest Module which is in my workspace
If i remove "extends MainResourceController" from the controller definition , the omod generated on clean install gets imported and started with no error in OpenMRS .. but then this(
http://pastebin.com/7RZUnbEX) error is returned on doing any request in rest api.
I also tried creating a separate controller for Rest but it also gave spring bean initialization error similar to above
can you please suggest something for solving the issue , or an alternative approach I can take.
thanks