分布式网上商城项目-solr搜索功能错误
Posted thyhome
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了分布式网上商城项目-solr搜索功能错误相关的知识,希望对你有一定的参考价值。
1、RuntimeException错误
1 java.lang.RuntimeException: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.thyonline.taotao.search.mapper.SearchItemMapper.SearchItemList 2 3 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.thyonline.taotao.search.mapper.SearchItemMapper.SearchItemList 4 5 at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189) 6 7 at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43) 8 9 at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58) 10 11 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51) 12 13 at com.sun.proxy.$Proxy34.SearchItemList(Unknown Source) 14 15 at cn.thyonline.taotao.search.service.impl.SearchItemServiceImpl.importAllItems(SearchItemServiceImpl.java:24) 16 17 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 18 19 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 20 21 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 22 23 at java.base/java.lang.reflect.Method.invoke(Method.java:564) 24 25 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 26 27 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 28 29 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 30 31 at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) 32 33 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) 34 35 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 36 37 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 38 39 at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) 40 41 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) 42 43 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 44 45 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 46 47 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) 48 49 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 50 51 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) 52 53 at com.sun.proxy.$Proxy35.importAllItems(Unknown Source) 54 55 at com.alibaba.dubbo.common.bytecode.Wrapper0.invokeMethod(Wrapper0.java) 56 57 at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46) 58 59 at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72) 60 61 at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) 62 63 at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64) 64 65 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 66 67 at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75) 68 69 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 70 71 at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42) 72 73 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 74 75 at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78) 76 77 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 78 79 at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60) 80 81 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 82 83 at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112) 84 85 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 86 87 at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38) 88 89 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 90 91 at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38) 92 93 at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) 94 95 at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108) 96 97 at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84) 98 99 at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170) 100 101 at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52) 102 103 at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:82) 104 105 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 106 107 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 108 109 at java.base/java.lang.Thread.run(Thread.java:844)
但是查看target文件发现查看报错信息可以看见是mapper绑定无效
Mapper文件已经放置在一个文件夹,再检查两个文件发现是select语句的ID没有对应上
2、请求超时错误
1 com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method importAllItems in the service cn.thyonline.taotao.search.service.SearchItemService. Tried 3 times of the providers [192.168.199.139:20882] (1/1) from the registry 192.168.25.128:2181 on the consumer 192.168.199.139 using the dubbo version 2.5.3. Last error is: Invoke remote method timeout. method: importAllItems, provider: dubbo://192.168.199.139:20882/cn.thyonline.taotao.search.service.SearchItemService?anyhost=true&application=taotao-manager-web&check=false&dubbo=2.5.3&interface=cn.thyonline.taotao.search.service.SearchItemService&methods=importAllItems&pid=3208&revision=0.0.1-SNAPSHOT&side=consumer×tamp=1528390391677, cause: Waiting server-side response timeout. start time: 2018-06-08 00:53:16.967, end time: 2018-06-08 00:53:17.968, client elapsed: 0 ms, server elapsed: 1001 ms, timeout: 1000 ms, request: Request [id=2, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=importAllItems, parameterTypes=[], arguments=[], attachments={path=cn.thyonline.taotao.search.service.SearchItemService, interface=cn.thyonline.taotao.search.service.SearchItemService, version=0.0.0}]], channel: /192.168.199.139:11038 -> /192.168.199.139:20882
Web层请求超时
但是检查search层在查询数据库前后打印
1 System.out.println("开始查询商品!"); 2 3 List<SearchItem> items = mapper.searchItemList(); 4 5 //2、创建solrServer对象,将商品信息通过SolrInputDocument存入 6 7 System.out.println("查询到的商品数量:"+items.size());
并且打印出来了数据说明mapper映射文件也没有问题。重新开始测试,发现后台两条数据都打印了出来,证明请求从controller层传递到了service层,dubbo连接没有问题。
那证明一件事情就是这次连接因为要连接solr导致耗时很长,使得超出了dubbo的默认连接时间从而失败,修改dubbo在service层和controller层的配置:
1 <!-- 名字不能够重复,和随便,用于计算依赖关系,服务调用的情况 --> 2 3 <dubbo:application name="taotao-search" /> 4 5 <!-- 使用zookeeper注册协议 --> 6 7 <dubbo:registry protocol="zookeeper" address="192.168.25.128:2181" /> 8 9 <!-- 使用dubbo协议,暴露服务的端口 --> 10 11 <dubbo:protocol name="dubbo" port="20882" /> 12 13 <!-- 发布服务 --> 14 15 <dubbo:service interface="cn.thyonline.taotao.search.service.SearchItemService" ref="searchItemServiceImpl" timeout="300000"/>
查看solr数据修改连接超时为5分钟,再次测试,连接成功
Solr数据导入成功
以上是关于分布式网上商城项目-solr搜索功能错误的主要内容,如果未能解决你的问题,请参考以下文章
JAVAEE——宜立方商城08:Zookeeper+SolrCloud集群搭建搜索功能切换到集群版Activemq消息队列搭建与使用