java - Dubbo无法序列化SolrPageRequest

标签 java rpc spring-data-solr

我正在使用Dubbo制作一个微服务,用于使用spring-data-solr进行文档搜索,我的Dubbo版本是2.5.3,我的spring-data-solr版本是2.0.5。我的导出界面是这样的:

import edu.whu.irlab.scholarreader.domain.Paper;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.query.result.HighlightPage;
import org.springframework.data.solr.repository.Boost;
import org.springframework.data.solr.repository.Highlight;

import java.util.Collection;

public interface PaperService {

    Page<Paper> findByTitle(String title, Pageable page);

    Page<Paper> findByContent(String content, Pageable page);

    Page<Paper> findByTitleOrAbsText(@Boost(2) String title, String absText, Pageable page);

    @Highlight
    HighlightPage<Paper> findByIdIn(Collection<String> id, Pageable page);

    //    @Query(value = "name:?0")
//    @Facet(fields = { "cat" }, limit=20)
//    FacetPage<Paper> findByNameAndFacetOnCategory(String name, Pageable page);
    Page<Paper> findAll(Pageable pageable);

    Page<Paper> findByKeywords(String keywords, Pageable pageable);

    Page<Paper> findByAuthors(String authors, Pageable pageable);

    Page<Paper> findByAbsText(String absText, Pageable pageable);

    Page<Paper> findByAffiliations(String affiliations, Pageable pageable);

    Page<Paper> findBySearchFields(String searchFields, Pageable pageable);

}

在提供程序中我有实现类:

import edu.whu.irlab.scholarreader.dao.solr.SolrPaperRepository;
import edu.whu.irlab.scholarreader.domain.Paper;
import edu.whu.irlab.scholarreader.export.PaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.query.result.HighlightPage;
import org.springframework.data.solr.repository.Boost;

import java.util.Collection;

public class PaperServiceImpl implements PaperService {

    @Autowired
    private SolrPaperRepository solrPaperRepository;

    public PaperServiceImpl() {

    }


    @Override
    public Page<Paper> findByTitle(String title, Pageable page) {
        return solrPaperRepository.findByTitle(title, page);
    }

    @Override
    public Page<Paper> findByContent(String content, Pageable page) {
        return solrPaperRepository.findByContent(content, page);
    }

    @Override
    public Page<Paper> findByTitleOrAbsText(@Boost(2) String title, String absText, Pageable page) {
        return solrPaperRepository.findByTitleOrAbsText(title, absText, page);
    }

    @Override
    public HighlightPage<Paper> findByIdIn(Collection<String> id, Pageable page) {
        return solrPaperRepository.findByIdIn(id, page);
    }

    @Override
    public Page<Paper> findAll(Pageable pageable) {
        return solrPaperRepository.findAll(pageable);
    }

    @Override
    public Page<Paper> findByKeywords(String keywords, Pageable pageable) {
        return solrPaperRepository.findByKeywords(keywords, pageable);
    }

    @Override
    public Page<Paper> findByAuthors(String authors, Pageable pageable) {
        return solrPaperRepository.findByAuthors(authors, pageable);
    }

    @Override
    public Page<Paper> findByAbsText(String absText, Pageable pageable) {
        return solrPaperRepository.findByAbsText(absText, pageable);
    }

    @Override
    public Page<Paper> findByAffiliations(String affiliations, Pageable pageable) {
        return solrPaperRepository.findByAffiliations(affiliations, pageable);
    }

    @Override
    public Page<Paper> findBySearchFields(String searchFields, Pageable pageable) {
        return solrPaperRepository.findBySearchFields(searchFields, pageable);
    }
}

在Dubbo-consumer中,当我调用paperService.findBySearchFields(searchStr, new PageRequest(pageNumber - 1, pageSize));时,发生错误:

17:35:18.794 [qtp477643715-33] ERROR 500.jsp - Failed to invoke the method findBySearchFields in the service edu.whu.irlab.scholarreader.export.PaperService. Tried 3 times of the providers [10.129.166.252:20880] (1/1) from the registry 127.0.0.1:2181 on the consumer 10.129.166.252 using the dubbo version 2.4.10. Last error is: Failed to invoke remote method: findBySearchFields, provider: dubbo://10.129.166.252:20880/edu.whu.irlab.scholarreader.export.PaperService?anyhost=true&application=dubbo-consumer&check=false&dubbo=2.4.10&interface=edu.whu.irlab.scholarreader.export.PaperService&methods=findByContent,findByIdIn,findByAuthors,findByAffiliations,findBySearchFields,findByTitleOrAbsText,findByTitle,findByAbsText,findAll,findByKeywords&pid=34732&revision=1.0-SNAPSHOT&side=consumer&timestamp=1481362482218, cause: Fail to decode request due to: RpcInvocation [methodName=findBySearchFields, parameterTypes=[class java.lang.String, interface org.springframework.data.domain.Pageable], arguments=null, attachments={path=edu.whu.irlab.scholarreader.export.PaperService, input=355, dubbo=2.4.10, version=0.0.0}]
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method findBySearchFields in the service edu.whu.irlab.scholarreader.export.PaperService. Tried 3 times of the providers [10.129.166.252:20880] (1/1) from the registry 127.0.0.1:2181 on the consumer 10.129.166.252 using the dubbo version 2.4.10. Last error is: Failed to invoke remote method: findBySearchFields, provider: dubbo://10.129.166.252:20880/edu.whu.irlab.scholarreader.export.PaperService?anyhost=true&application=dubbo-consumer&check=false&dubbo=2.4.10&interface=edu.whu.irlab.scholarreader.export.PaperService&methods=findByContent,findByIdIn,findByAuthors,findByAffiliations,findBySearchFields,findByTitleOrAbsText,findByTitle,findByAbsText,findAll,findByKeywords&pid=34732&revision=1.0-SNAPSHOT&side=consumer&timestamp=1481362482218, cause: Fail to decode request due to: RpcInvocation [methodName=findBySearchFields, parameterTypes=[class java.lang.String, interface org.springframework.data.domain.Pageable], arguments=null, attachments={path=edu.whu.irlab.scholarreader.export.PaperService, input=355, dubbo=2.4.10, version=0.0.0}]
    at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:101)
    at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:226)
    at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72)
    at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
    at com.alibaba.dubbo.common.bytecode.proxy0.findBySearchFields(proxy0.java)
    at edu.whu.irlab.scholarreader.web.paper.PaperController.list(PaperController.java:47)
    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:497)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1317)
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
    at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:178)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1288)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:443)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:556)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1044)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:372)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:978)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:369)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:486)
    at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:933)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:995)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.alibaba.dubbo.remoting.RemotingException: Fail to decode request due to: RpcInvocation [methodName=findBySearchFields, parameterTypes=[class java.lang.String, interface org.springframework.data.domain.Pageable], arguments=null, attachments={path=edu.whu.irlab.scholarreader.export.PaperService, input=355, dubbo=2.4.10, version=0.0.0}]
    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.returnFromResponse(DefaultFuture.java:190)
    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:110)
    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:84)
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96)
    at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144)
    at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74)
    at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
    at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
    at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48)
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
    at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
    at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77)
    ... 72 common frames omitted

org.springframework.data.domain.PageRequest实现了java.io.Serialized,但是org.springframework.data.solr.core.query。 SolrPageRequest 没有。 PageRequest 自动转换为 SolrPageRequest。 那么,我该如何解决这个问题呢?如果是这样,是不是说我无法用Dubbo导出我的spring-data-solr服务?

最佳答案

pageable默认实现类是PageRequest,并不是没有params构造函数,但是dubbo需要这个方法来解码,所以无法解码

关于java - Dubbo无法序列化SolrPageRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41074174/

相关文章:

rabbitmq - 使用 RabbitMQ 时为每个远程方法创建一个队列?

java - 注入(inject)的 SolrTemplate 资源未连接到 HttpSolrServer

java - 如何使用 spring-data-solr 在空间搜索中返回距离和分数

java - 如何查看给定目录中所有 jar 的所有内容?

java - 使用 javax.mail 向 BCC 收件人发送电子邮件

Java 效率 : Fullscreen Exclusive Mode

java - 如何在 JAXB Adapter 中使用属性作为键、使用整个元素作为值将复杂元素解析为 Map

java - RPC和调用web服务有什么区别

go - golang rpc找不到服务

java - 响应式(Reactive) spring-data-solr 存储库