We are looking to use openmrs as webservice to interact with db. ie from our application we invoke openmrs rest. Can you help if we have any standard document with steps to configure. We tried adding webservicew rest module but we are seeing resource not found exception for /person or /users for the endpoints. Please share if you we have any documents for configuration steps to consume openmrs as rest service.
@prasadreddy hope these can help https://wiki.openmrs.org/display/docs/REST+Web+Services+API+For+Clients https://wiki.openmrs.org/display/docs/REST+Web+Service+Resources+in+OpenMRS+1.9#RESTWebServiceResourcesinOpenMRS1.9-Privilege https://rest.openmrs.org/#openmrs-rest-api
@gcliff thank you for the references. We have openmrs war build on top of master branch openmrs-core and rest module version 2.29.0. it is throwing an exception so we added legacyui module. But we are getting resource not found exception for /person. Do we need to add any other modules to consume openmrs-core as web service
@prasadreddyin the simplest way would be to use the sdk to set up openmrs platform and do the rest api calls
ideally it should work with the legacy and rest module available , may be you can share the url your using to get the person resource
@gcliff below is the url i am using http://localhost:8008/openmrs/ws/rest/v1/person/5f87c042-6814-11e8-923f-e9a88dcb533f
(we changed port number on tomcat)
We are getting below excception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.openmrs.module.webservices.rest.web.response.UnknownResourceException: Unknown resource: v1/person org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) javax.servlet.http.HttpServlet.service(HttpServlet.java:626) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) javax.servlet.http.HttpServlet.service(HttpServlet.java:733) org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:60) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:73) org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:65) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71) org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:105) org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71) org.openmrs.module.webservices.rest.web.filter.ContentTypeFilter.doFilter(ContentTypeFilter.java:64) org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71) org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:106) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71) org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:57) org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:105) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) org.springframework.orm.hibernate5.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:156) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:108) org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:108) org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:108) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) Root Cause
org.openmrs.module.webservices.rest.web.response.UnknownResourceException: Unknown resource: v1/person org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl.getResourceByName(RestServiceImpl.java:419) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) org.springframework.cache.interceptor.CacheInterceptor.lambda$invoke$0(CacheInterceptor.java:54) org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:351) org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:64) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:123) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) com.sun.proxy.$Proxy179.getResourceByName(Unknown Source) org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.retrieve(MainResourceController.java:74) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
@prasadreddy i have fixed it here https://issues.openmrs.org/browse/RESTWS-815 and attached a compiled rest webservices module with the fix.
Thank you @dkayiwa for quick fix. After using webservices.rest-2.30.0-SNAPSHOT.98cb97 and legacyui-1.8.0 modules and war file build on top of master branch of openmrs-core we are getting below exception while starting the application on tomcat9
Dec 29, 2020 1:41:14 PM org.apache.catalina.session.StandardSession doReadObject WARNING: Cannot deserialize session attribute [__openmrs_user_context] for session [3D6C265323E716E12ACDA3370FB8552C] Dec 29, 2020 1:41:14 PM org.apache.catalina.session.StandardManager startInternal SEVERE: Exception loading sessions from persistent storage java.lang.ClassCastException: java.io.ObjectStreamClass cannot be cast to java.lang.String at java.io.ObjectInputStream.readTypeString(ObjectInputStream.java:1650) at java.io.ObjectStreamClass.readNonProxy(ObjectStreamClass.java:803) at java.io.ObjectInputStream.readClassDescriptor(ObjectInputStream.java:891) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1857) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1751) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2042) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1573) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:431)
we are getting below exception while using tomcat8 so configured on tomcat9
SEVERE: Unable to process Jar entry [module-info.class] from Jar [file:/C:/FL/Git_Storage/WS_openmrs-core/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/openmrs-webapp/WEB-INF/lib/jaxb-runtime-2.3.1.jar] for annotations org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19 at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:97) at org.apache.tomcat.util.bcel.classfile.ConstantPool.(ConstantPool.java:55) at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:176) at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:85) at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2042) at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1988) at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1958) at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1912) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1157) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:779) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:306) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5202) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
@gcliff he does not have to use Java 8, unless you do not trust the platform that you released. Tomcat 9 should also be fine. @prasadreddy does the exception you got after upgrading the rest module prevent the application from starting? It shouldn’t, as far as I know.
we are able to start the application but with exception mentioned above
my bad ,
was assuming he is running on core 2.3.2…
Thanks for the clarification