The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
123
stars
76
forks
source link
Canonical URL querying fails when used for more than one entity #111
Resolving this inconvenience will further establish your library as a reliable, effective, and battle-tested utility. πͺπΌ
The Issue
The issue is that when we try to call an OData-complient endpoint which queries more than one entity without the explicit key notation /entity(ENTITY_ID), in contrast to /entity(id=ENTITY_ID), we receive the following error.
{ "error": { "code": null, "message": "The key value '' is invalid. Use odata-debug query parameter with value one of the following formats: json,html,download for more information." } }
The issue can be easily reproduced by calling an OData-complient endpoint which queries two entities in the following format: $URL/entityOne($ENTITY_ONE_ID)/entityTwo($ENTITY_TWO_ID).
Notes
If we use the explicit key notation, i.e. $URL/entityOne(id=$ENTITY_ONE_ID)/entityTwo(id=$ENTITY_TWO_ID), we don't face this issue and everything works fine.
If it can help you get a better understanding of issue, you can check out the source code of the service in which we're using the Olingo library.
Stack Trace
org.apache.olingo.server.core.uri.parser.UriParserSemanticException: The key value is not valid.
at org.apache.olingo.server.core.uri.parser.ParserHelper.parseKeyPredicate(ParserHelper.java:330) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.uri.parser.ParserHelper.parseNavigationKeyPredicate(ParserHelper.java:281) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.uri.parser.ResourcePathParser.navigationOrProperty(ResourcePathParser.java:279) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.uri.parser.ResourcePathParser.parsePathSegment(ResourcePathParser.java:101) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.uri.parser.Parser.parseUri(Parser.java:234) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.ODataHandlerImpl.processInternal(ODataHandlerImpl.java:143) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.ODataHandlerImpl.process(ODataHandlerImpl.java:85) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.ODataHttpHandlerImpl.process(ODataHttpHandlerImpl.java:74) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at org.apache.olingo.server.core.ODataHttpHandlerImpl.process(ODataHttpHandlerImpl.java:88) ~[odata-server-core-4.7.0.jar!/:4.7.0]
at com.sap.olingo.jpa.processor.core.api.JPAODataGetHandler.processInternal(JPAODataGetHandler.java:162) ~[odata-jpa-processor-0.3.8-SNAPSHOT.jar!/:na]
at com.sap.olingo.jpa.processor.core.api.JPAODataGetHandler.process(JPAODataGetHandler.java:98) ~[odata-jpa-processor-0.3.8-SNAPSHOT.jar!/:na]
at com.sap.cloud.cmp.ord.service.controller.ODataController.handleODataRequest(ODataController.java:36) ~[classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_275]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_275]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_275]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_275]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) ~[tomcat-embed-core-9.0.44.jar!/:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.5.jar!/:5.3.5]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.44.jar!/:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at com.sap.cloud.cmp.ord.service.filter.JsonPostProcessFilter.doFilter(JsonPostProcessFilter.java:36) ~[classes!/:0.0.1-SNAPSHOT]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) ~[spring-boot-actuator-2.4.4.jar!/:2.4.4]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.5.jar!/:5.3.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at com.sap.cloud.cmp.ord.service.filter.ResponseFormatFilter.doFilter(ResponseFormatFilter.java:61) ~[classes!/:0.0.1-SNAPSHOT]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_275]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_275]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.44.jar!/:9.0.44]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_275]
Hi guys ππΌ,
Our team is using your Olingo library and, unfortunately, we stumbled upon an issue. π
It's somehow closely related to this section of the OData specification.
Resolving this inconvenience will further establish your library as a reliable, effective, and battle-tested utility. πͺπΌ
The Issue
The issue is that when we try to call an OData-complient endpoint which queries more than one entity without the explicit key notation
/entity(ENTITY_ID)
, in contrast to/entity(id=ENTITY_ID)
, we receive the following error.{ "error": { "code": null, "message": "The key value '' is invalid. Use odata-debug query parameter with value one of the following formats: json,html,download for more information." } }
The issue can be easily reproduced by calling an OData-complient endpoint which queries two entities in the following format:
$URL/entityOne($ENTITY_ONE_ID)/entityTwo($ENTITY_TWO_ID)
.Notes
If we use the explicit key notation, i.e.
$URL/entityOne(id=$ENTITY_ONE_ID)/entityTwo(id=$ENTITY_TWO_ID)
, we don't face this issue and everything works fine.If it can help you get a better understanding of issue, you can check out the source code of the service in which we're using the Olingo library.
Stack Trace