# Error - RestClient java.lang.RuntimeException: error while performing request

**URL:** <https://discuss.elastic.co/t/error-restclient-java-lang-runtimeexception-error-while-performing-request/194303>\
**Category:** Elasticsearch\
**Created:** [August 7, 2019, 6:09pm UTC](https://discuss.elastic.co/t/error-restclient-java-lang-runtimeexception-error-while-performing-request/194303 "2019-08-07T18:09:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![venky003](https://avatars.discourse-cdn.com/v4/letter/v/a5b964/32.png) [@venky003](https://discuss.elastic.co/u/venky003)\
**Post date:** [August 7, 2019, 6:09pm UTC](https://discuss.elastic.co/t/error-restclient-java-lang-runtimeexception-error-while-performing-request/194303/1 "2019-08-07T18:09:20Z")

</div>

We are getting this error regularly in our production environment.  
We are building the RestClient using default configurations.

```
public RestClient build() {
            if (this.failureListener == null) {
                this.failureListener = new FailureListener();
            }
            CloseableHttpAsyncClient httpClient = this.createHttpClient();
            RestClient restClient = new RestClient(httpClient, (long)this.maxRetryTimeout, this.defaultHeaders, this.hosts, this.pathPrefix, this.failureListener);
            httpClient.start();
            return restClient;
        }

```

Stacktrace:

```
com.repository.exception.RepositoryServicesException: java.lang.RuntimeException: error while performing request

at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.3.23.RELEASE.jar!/:4.3.23.RELEASE]

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:736) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:84) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at sun.reflect.GeneratedMethodAccessor185.invoke(Unknown Source) ~[?:?]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]

at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:84) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at com.enterpriseimaging.documentapi.service.RouteService.route(RouteService.java:104) ~[classes!/:0.0.739]

at com.enterpriseimaging.documentapi.config.DocumentRouterAspect.around(DocumentRouterAspect.java:37) ~[classes!/:0.0.739]

at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source) ~[?:?]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]

at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671) ~[spring-aop-4.3.22.RELEASE.jar!/:4.3.22.RELEASE]

at com...enterpriseimaging.documentapi.service.impl.DocumentSearchServiceImpl$$EnhancerBySpringCGLIB$$83151592.searchDocument(<generated>) ~[classes!/:0.0.739]

at com...enterpriseimaging.documentapi.rest.v3.DocumentResource.lambda$asyncGetList$2(DocumentResource.java:166) ~[classes!/:0.0.739]

at com.....engine.core.concurrent.FunctionRequestContextHandlerBaseImpl.copyScope(FunctionRequestContextHandlerBaseImpl.java:50) [.-core-concurrency-2.8.3.RELEASE.jar!/:?]

at com.....engine.core.concurrent.FunctionRequestContextHandlerBaseImpl.copyScope(FunctionRequestContextHandlerBaseImpl.java:64) [.-core-concurrency-2.8.3.RELEASE.jar!/:?]

at com.....engine.core.concurrent.RequestContextAwareCallable.call(RequestContextAwareCallable.java:57) [.-core-concurrency-2.8.3.RELEASE.jar!/:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_191]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_191]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_191]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]

Caused by: java.lang.RuntimeException: error while performing request

at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:681) ~[elasticsearch-rest-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestClient.performRequest(RestClient.java:219) ~[elasticsearch-rest-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestClient.performRequest(RestClient.java:191) ~[elasticsearch-rest-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:396) ~[elasticsearch-rest-high-level-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:382) ~[elasticsearch-rest-high-level-client-5.6.4.jar!/:5.6.4]

at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:323) ~[elasticsearch-rest-high-level-client-5.6.4.jar!/:5.6.4]

at com...enterpriseimaging.repository.dao.impl.RepositoryDAOImpl.executeRestSearchQuery(RepositoryDAOImpl.java:268) ~[ei-repository-library-0.0.68.jar!/:?]

at com...enterpriseimaging.repository.dao.impl.RepositoryDAOImpl.lambda$searchRepository$0(RepositoryDAOImpl.java:132) ~[ei-repository-library-0.0.68.jar!/:?]

at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) ~[?:1.8.0_191]

... 1 more

Caused by: java.util.concurrent.TimeoutException

```

Do we have to change any configurations while creating the RestClient. I am not sure why it is happening.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 9, 2019, 6:09am UTC](https://discuss.elastic.co/t/error-restclient-java-lang-runtimeexception-error-while-performing-request/194303/2 "2019-08-09T06:09:53Z")

</div>

is there any chance the stack trace is even longer? from a quick peek it looks, as if a HTTP request is timing out while being sent to elasticsearch. Could this happen?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 6, 2019, 6:09am UTC](https://discuss.elastic.co/t/error-restclient-java-lang-runtimeexception-error-while-performing-request/194303/3 "2019-09-06T06:09:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
