avniproject / integration-service

Service for integration Avni with other systems
GNU Affero General Public License v3.0
0 stars 2 forks source link

Cannot find some inventories #115

Closed mahalakshme closed 9 months ago

mahalakshme commented 9 months ago

https://avni.freshdesk.com/a/tickets/3422

himeshr commented 9 months ago

Root cause for this was expired token, during sync of ImplementationInventories from 01 Apr 2023.

2024-01-17 07:41:03,662 DEBUG SpringTaskScheduler-18 [worker.goonj.InventoryEventWorker] Processing implementation inventory: name Contributed-crockery-2023/UTR/ACC-29985/RAJ/541-785 || uuid a2BC5000001eEOfMAM
2024-01-17 07:41:03,729 INFO  SpringTaskScheduler-18 [avni.client.AvniHttpClient] POST: /api/subject
2024-01-17 07:41:03,729 DEBUG SpringTaskScheduler-18 [avni.client.AvniHttpClient] POST https://app.avniproject.org/api/subject
2024-01-17 07:41:03,766 ERROR SpringTaskScheduler-18 [avni.client.AvniHttpClient] URI: https://app.avniproject.org/api/subject, Errored Request body: {"Subject type":"Inventory Item","Address":"Rajasthan, Banswara","Registration date":"2023-07-10","observations":{"Initial Quantity":785.0,"Center / Field office":"Goonj Banswara","Dispatch Line Item Id":null,"Purchased/ Created/ Received":"Received","Purchase Kit name":null,"Bill name":null,"Other material name":"crockery","Unit":"Nos","Dispatch Status Id":"a1AC500000DvtSEMAZ","Dispatch Received Date":"2023-07-09","Dispatch Received Status Line Item Id":"a24C50000002hCtIAI","Material sub category":"Others","Dispatch Status Name":"2023/UTR/ACC-29985/RAJ/541","Material Name":"crockery","Account  name":"Goonj Rishikesh Dhalwala","Current Quantity":729.0,"Type Of Material":"Contributed item","Vehicle type":null,"Material type":"Miscellaneous","Implementation Inventory Id":"a2BC5000001eEOfMAM"},"First name":"Contributed-crockery-2023/UTR/ACC-29985/RAJ/541-785","Voided":false,"External ID":"a2BC5000001eEOfMAM"}
2024-01-17 07:41:03,766 ERROR SpringTaskScheduler-18 [worker.goonj.GoonjEventWorker] Goonj Inventory a2BC5000001eEOfMAM could not be synced to Goonj Salesforce.
org.springframework.web.client.HttpClientErrorException$Unauthorized: 401 : "{"timestamp":"2024-01-17T07:41:03.738+00:00","status":401,"error":"Unauthorized","message":"org.avni.server.domain.accessControl.AvniNoUserSessionException: com.auth0.jwt.exceptions.TokenExpiredException: The Token has expired on Wed Jan 17 07:05:05 UTC 2024.\n\tat org.avni.server.framework.security.AuthService.authenticateByToken(AuthService.java:55)\n\tat org.avni.server.framework.security.AuthenticationFilter.doFilterInternal(AuthenticationFilter.java:70)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)\n\tat org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)\n\tat org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)\n\tat org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)\n\tat org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)\n\tat org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)\n\tat org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)\n\tat org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)\n\tat org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)\n\tat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)\n\tat org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)\n\tat org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)\n\tat org.keycloak.adapters.tomcat.AbstractAuthenticatedActionsValve.invoke(AbstractAuthenticatedActionsValve.java:67)\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481)\n\tat org.keycloak.adapters.tomcat.AbstractKeycloakAuthenticatorValve.invoke(AbstractKeycloakAuthenticatorValve.java:181)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)\n\tat org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670)\n\tat org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:765)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1790)\n\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)\n\tat org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)\n\tat org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:750)\nCaused by: com.auth0.jwt.exceptions.TokenExpiredException: The Token has expired on Wed Jan 17 07:05:05 UTC 2024.\n\tat com.auth0.jwt.JWTVerifier.assertDateIsFuture(JWTVerifier.java:441)\n\tat com.auth0.jwt.JWTVerifier.assertValidDateClaim(JWTVerifier.java:432)\n\tat com.auth0.jwt.JWTVerifier.verifyClaims(JWTVerifier.java:373)\n\tat com.auth0.jwt.JWTVerifier.verify(JWTVerifier.java:355)\n\tat org.avni.server.service.BaseIAMService.verifyAndDecodeToken(BaseIAMService.java:84)\n\tat org.avni.server.service.BaseIAMService.getUserFromToken(BaseIAMService.java:44)\n\tat org.avni.server.framework.security.AuthService.authenticateByToken(AuthService.java:52)\n\t... 55 more\n","path":"/api/subject"}"
    at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:105)
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:168)
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:122)
    at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:819)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:777)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:751)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:621)
    at org.avni_integration_service.avni.client.AvniHttpClient.getResponseEntity(AvniHttpClient.java:55)
    at org.avni_integration_service.avni.client.AvniHttpClient.post(AvniHttpClient.java:81)
    at org.avni_integration_service.avni.repository.AvniSubjectRepository.create(AvniSubjectRepository.java:80)
    at org.avni_integration_service.goonj.worker.goonj.InventoryEventWorker.processImplementationInventory(InventoryEventWorker.java:61)
    at org.avni_integration_service.goonj.worker.goonj.InventoryEventWorker.process(InventoryEventWorker.java:49)
    at org.avni_integration_service.goonj.worker.goonj.InventoryEventWorker.processError(InventoryEventWorker.java:71)
    at org.avni_integration_service.goonj.worker.AvniGoonjErrorRecordsWorker.retryErroredEntitySync(AvniGoonjErrorRecordsWorker.java:98)
    at org.avni_integration_service.goonj.worker.AvniGoonjErrorRecordsWorker.process(AvniGoonjErrorRecordsWorker.java:88)
    at org.avni_integration_service.goonj.job.AvniGoonjFullErrorJob.execute(AvniGoonjFullErrorJob.java:43)
    at org.avni_integration_service.scheduler.IntegrationJobScheduler.lambda$scheduleGoonj$1(IntegrationJobScheduler.java:97)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:95)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
2024-01-17 07:41:03,837 INFO  SpringTaskScheduler-18 [goonj.service.AvniGoonjErrorService] New error for entity uuid a2BC5000001eEOfMAM, and type Inventory
2024-01-17 07:41:03,887 DEBUG SpringTaskScheduler-18 [goonj.service.TokenService] Token still valid