Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InsertResult: "query did not return a unique result: 2" #1167

Closed
cWam-zz opened this issue Oct 14, 2021 · 5 comments
Closed

InsertResult: "query did not return a unique result: 2" #1167

cWam-zz opened this issue Oct 14, 2021 · 5 comments
Labels

Comments

@cWam-zz
Copy link

cWam-zz commented Oct 14, 2021

Hello,
A no "NoApplicableCode" exception arised during an InsertResult request. We use SOS 5.2.6 and I describe below the process we used for data record through the SOS client interface.

  1. InsertFeatureIfInterest -> POX SOS 2.0.0 (polygon FOIs encoded in GML)
  2. InsertSensor -> SOAP with SensorML 2.0 SOS 2.0.0
  3. InsertResultTemplate -> JSON SOS 2.0.0 (polygon FOIs encoded in GeoJSON)
  4. InsertResult -> JSON SOS 2.0.0

In this example there are several FOIs and several observableProperties associated to the sensor. We were able to record two sets of results associated with two different FOIs but it seems that for the other FOIs, the InsertResult request failes. In the client interface, we get this message:
{ "version": "2.0.0", "exceptions": [ { "code": "NoApplicableCode", "text": "[EXCEPTION]: \nquery did not return a unique result: 2\n" } ] }

The logs message is as follow:

WARN [http-nio-8080-exec-8] [JSONBinding.java:94] Unexpected error
org.n52.shetland.ogc.ows.exception.NoApplicableCodeException: null
	at org.n52.sos.ds.hibernate.InsertResultHandler.insertResult(InsertResultHandler.java:240)
	at org.n52.sos.request.operator.SosInsertResultOperatorV20.receive(SosInsertResultOperatorV20.java:75)
	at org.n52.sos.request.operator.SosInsertResultOperatorV20.receive(SosInsertResultOperatorV20.java:51)
	at org.n52.sos.request.operator.AbstractRequestOperator.receiveRequest(AbstractRequestOperator.java:380)
	at org.n52.sos.request.operator.AbstractTransactionalRequestOperator.receiveRequest(AbstractTransactionalRequestOperator.java:88)
	at org.n52.iceland.service.operator.GenericServiceOperator.receiveRequest(GenericServiceOperator.java:100)
	at org.n52.iceland.binding.json.JSONBinding.doPostOperation(JSONBinding.java:90)
	at org.n52.iceland.service.Service.post(Service.java:150)
	at sun.reflect.GeneratedMethodAccessor854.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:209)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:209)
	at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:244)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.NonUniqueResultException: query did not return a unique result: 2
	at org.hibernate.query.internal.AbstractProducedQuery.uniqueElement(AbstractProducedQuery.java:1600)
	at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:392)
	at org.n52.sos.ds.hibernate.dao.observation.series.AbstractSeriesDAO.getSeries(AbstractSeriesDAO.java:274)
	at org.n52.sos.ds.hibernate.InsertResultHandler.insertResult(InsertResultHandler.java:188)
	... 59 common frames omitted

We checked the database but the new observations were not recorded.

Is there anything we are doing wrong?

NB: In this process, FOI descriptions are done twice (during the InsertFeatureOfInterest and during the InsertResultTemplate). We do not knwow if there is a way to avoid this double recording.

Thank you very much.

@CarstenHollmann
Copy link

You are not doing anything wrong, it seems to be a bug in the SOS which I was able to reproduce.

NB: In this process, FOI descriptions are done twice (during the InsertFeatureOfInterest and during the InsertResultTemplate). We do not knwow if there is a way to avoid this double recording.

You can use the identifier of the featureOfInterest in the InsertResultTemplate request.
The identifier is the gml:identifier you have defined in the InsertFeatureOfInterest request.
In the InsertResultTemplate JSON request it should look like this:

... "featureOfInterest": "THE_IDENTIFIER", ...

@cWam-zz
Copy link
Author

cWam-zz commented Oct 29, 2021

Dear Carsten,
Thank you for your reply.

I did as you specified by uniquely using the featureOfInterest identifier in the insertResult request. Here is the process I used :

  1. deleteResultTemplate for the templates that I used with the complete description of the featureOfInterests
  2. insertResultTemplate by using the featureOfInterest identifier
  3. insertResult with the templateIdentifier

But I get the same message error.

Maybe a research element: the GetResultTemplate request does not work with a template identifier but by using an offering id and an observedProperty id. In this special case, my procedure (included in a unique offering) observes many observedProperty (3) on several featureOfInterests (33). With such a process, is it possible that using several featureOfInterests causes the problem, knowing that a template can be retireved with only an observedProperty and an offering?

Thank you very much.

@CarstenHollmann
Copy link

Hi,

we have prepared a new 5.2..x (5.2.11) release which contains a fix for this issue. With the new release you are able to insert results for the same offering/observedProperty and multiple featureOfInterest (more than two).

You can download the new release here: https://github.com/52North/SOS/releases/tag/v5.2.11

@cWam-zz
Copy link
Author

cWam-zz commented Nov 17, 2021

Dear Carsten,
Thank you for your reply and this new version.

I will check with this version.

Best regards.

@cWam-zz
Copy link
Author

cWam-zz commented Dec 21, 2021

Dear Carsten,
The new version works fine.

I close this issue. Thanks a lot.
Best regards.

@cWam-zz cWam-zz closed this as completed Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants