spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.18k stars 40.68k forks source link

spring-data-solr 2.1.x, SolrExceptionTranslator.translateExceptionIfPossible(SolrExceptionTranslator.java:79) #21919

Closed yuyu414 closed 4 years ago

yuyu414 commented 4 years ago

I used spring-data-solr 2.1.6, and I application.properties Set in configuration file spring.data.solr . host = external address, but after the program is started, there will be exceptions occasionally, which makes me puzzled. I hope you can help me, please。Why? image Please note that my Solr server is not on the local machine, and I have also configured it. The production environment is correct. this situation is sporadic, why? For example, if you request ten times, there will be an error in the picture one time. This error 127.0.0.1 is very confusing. I have configured it correctly, and the other nine times are normal. Why?

yuyu414 commented 4 years ago

Don't question my configuration. This happens occasionally

wilkinsona commented 4 years ago

Thanks for the report. Once Spring Boot has creating a SolrClient that uses a particular host, it will not change that configuration. One way that I think the host may change is if you're using spring.data.solr.zk-host and you're occasionally routed to a Solr instance running on localhost that isn't available. This is only a guess based on what you've described thus far. If you'd like us to spend some time trying to take a more informed look at your problem, please take the time to describe your setup and configuration in more detail.

yuyu414 commented 4 years ago

Thanks for your help,As you said:Once Spring Boot has creating a SolrClient that uses a particular host, it will not change that configuration. I agree. but,I'm sure I didn't use spring.data.solr.zk-host in my project.I'm confused, too. My project configuration: SpringBoot-2.1.6.RELEASE + spring-data-solr-2.1.6.RELEASE image image image image image Nothing else...

yuyu414 commented 4 years ago

Thanks for the report. Once Spring Boot has creating a SolrClient that uses a particular host, it will not change that configuration. One way that I think the host may change is if you're using spring.data.solr.zk-host and you're occasionally routed to a Solr instance running on localhost that isn't available. This is only a guess based on what you've described thus far. If you'd like us to spend some time trying to take a more informed look at your problem, please take the time to describe your setup and configuration in more detail.

This is my configuration. help me,Please!

yuyu414 commented 4 years ago
org.springframework.dao.DataAccessResourceFailureException: Connect to 127.0.0.1:8983 [/127.0.0.1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:8983 [/127.0.0.1] failed: Connection refused (Connection refused)
    at org.springframework.data.solr.core.SolrExceptionTranslator.translateExceptionIfPossible(SolrExceptionTranslator.java:79)
    at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:169)
    at org.springframework.data.solr.core.SolrTemplate.saveDocument(SolrTemplate.java:233)
    at org.springframework.data.solr.core.SolrOperations.saveDocument(SolrOperations.java:182)
    at com.huihe.bpp.biz.manager.offset.OffSetManagerImpl.addSolr(OffSetManagerImpl.java:715)
    at com.huihe.bpp.biz.manager.offset.OffSetManagerImpl.partake(OffSetManagerImpl.java:410)
    at com.huihe.bpp.web.controller.offset.OffSetController.doPartake(OffSetController.java:142)
    at com.huihe.bpp.web.controller.offset.OffSetController$$FastClassBySpringCGLIB$$fea180.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
    at com.huihe.bpp.web.interceptor.CustomMethodInterceptor.around(CustomMethodInterceptor.java:166)
    at sun.reflect.GeneratedMethodAccessor299.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
    at com.huihe.bpp.web.controller.offset.OffSetController$$EnhancerBySpringCGLIB$$99e5b182.doPartake(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    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:104)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:128)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:66)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:103)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:121)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
    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.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:8983 [/127.0.0.1] failed: Connection refused (Connection refused)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:542)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:255)
    at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:244)
    at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:194)
    at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:177)
    at org.springframework.data.solr.core.SolrTemplate.lambda$saveDocument$4(SolrTemplate.java:233)
    at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:167)
    ... 78 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    ... 94 common frames omitted
wilkinsona commented 4 years ago

The only other reason that I can see for the URL to change would be if something is calling setBaseURL on the HttpSolrClient. Neither Spring Boot nor Spring Data Solr will do that but maybe there is something in your application that is doing so.

I can't see any sign of a Spring Boot bug here. The client is configured by Spring Boot with the correct host and port and, beyond that point, it is no longer involved. As such, I am going to close this issue. To investigate further, I would, if possible, debug your application with a breakpoint on the setBaseURL method or modification of the baseURL field to identify what is changing the client's base URL.

yuyu414 commented 4 years ago

The only other reason that I can see for the URL to change would be if something is calling setBaseURL on the HttpSolrClient. Neither Spring Boot nor Spring Data Solr will do that but maybe there is something in your application that is doing so.

I can't see any sign of a Spring Boot bug here. The client is configured by Spring Boot with the correct host and port and, beyond that point, it is no longer involved. As such, I am going to close this issue. To investigate further, I would, if possible, debug your application with a breakpoint on the setBaseURL method or modification of the baseURL field to identify what is changing the client's base URL.

Well, apart from these basic dependencies, there is no redundant configuration. This is also a question I am confused about. It happened by chance. For example, I performed many savedocument operations. The first and second operations can be successful. This exception will appear when I perform the fifth operation, but the subsequent operations can still be successful when I perform the sixth operation

yuyu414 commented 4 years ago

I will also follow up on this issue and look forward to your results

yuyu414 commented 4 years ago

I know the reason. It's our problem. The operation and maintenance comrades have not been merged application.properties New code for。I'm sorry!!

SelimeSaglam commented 3 years ago

Hi , I have same problem .Please can you answer how solved problem.What code added in application.properties for this problem.