我正在使用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);
    }
}


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

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.Serializable,但org.springframework.data.solr.core.query.SolrPageRequest不实现。 PageRequest自动转换为SolrPageRequest。
那么,我该如何解决这个问题呢?如果是这样,是否表示我无法通过Dubbo导出spring-data-solr服务?

最佳答案

可分页的默认实现类为PageRequest,没有params构造函数,但是dubbo需要此方法进行解码,因此无法解码

10-04 23:18