Spring异常:org.springframework.expression.spel.SpelEvaluationException:EL1004E:(pos 8):方法调用:方法retrieveRecords(java.util.Vector)

问题描述 投票:0回答:1

我使用spring integration 2.2.1与int-jpa:inbound-channel-adapter。我得到了例外

org.springframework.expression.spel.SpelEvaluationException:EL1004E:(pos 8):方法调用:在foo.bar.ResponseProcessor类型上找不到方法retrieveRecords(java.util.Vector)

部署Web应用程序时。以下是spring配置文件中最密切相关的部分(重命名了一些内容):

....

 <bean id="responseProcessor" 
 class="foo.bar.ResponseProcessor">
 </bean>

<int-jpa:inbound-channel-adapter
    id="ResultsProcessor"
    channel="responseChannel"
    auto-startup="true"
    expect-single-result="false"
    delete-after-poll="false"
    entity-manager-factory="entityManagerFactory"
    entity-class="foo.bar.FooRequest">
    <int:poller 
        id="responsePoller" 
        fixed-rate="5000" 
        max-messages-per-poll="10">
    </int:poller>
</int-jpa:inbound-channel-adapter>

<int:channel id="responseChannel"/>

<int:service-activator 
    input-channel="responseChannel" 
    ref="responseProcessor" 
    method="retrieveOpenRecords" /> 

....

bean foo.bar.ResponseProcessor对应的类如下:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import foo.bar.FooRequest;


public class ResponseProcessor {

    /** The log. */
    private static Log log = LogFactory.getLog(ResponseProcessor.class);

    public void retrieveOpenRecords(FooRequest fr) {
        if (fr == null) {
            log.error("No open records were found");
            return;
        }
    }
}

,以及截断的堆栈跟踪输出(再次,有一些重写):

2018-02-28 09:41:04,811 INFO [org.springframework.context.support.DefaultLifecycleProcessor] - <Starting beans in phase 2147483647>
2018-02-28 09:41:04,817 INFO [org.springframework.integration.endpoint.SourcePollingChannelAdapter] - <started ResultsProcessor>
2018-02-28 09:41:04,821 INFO [org.springframework.web.context.ContextLoader] - <Root WebApplicationContext: initialization completed in 11377 ms>
2018-02-28 09:41:04,919 ERROR [org.springframework.integration.handler.LoggingHandler] - <org.springframework.integration.MessageHandlingException: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 8): Method call: Method retrieveOpenRecords(java.util.Vector) cannot be found on foo.bar.ResponseProcessor type
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:76)
at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:67)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.handleMessage(SourcePollingChannelAdapter.java:97)
at org.springframework.integration.endpoint.AbstractTransactionSynchronizingPollingEndpoint.doPoll(AbstractTransactionSynchronizingPollingEndpoint.java:82)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:144)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:236)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:231)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:51)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 8): Method call: Method retrieveOpenRecords(java.util.Vector) cannot be found on foo.bar.ResponseProcessor type
at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:177)
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:101)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:227)
at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:127)
at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)
... 28 more

我想知道我是否在服务激活器中的某处遗漏了一些有关retrieveOpenRecords方法签名的说明?感谢任何见解。谢谢

java spring spring-integration
1个回答
2
投票

<int-jpa:inbound-channel-adapter>的设计如下:

消息有效负载将是单个实体或实体列表

Reference Manual

更多的是你有expect-single-result="false",所以绝对不会只是一个FooRequest实体。

你应该这样:

public void retrieveOpenRecords(List<FooRequest> fr) {
© www.soinside.com 2019 - 2024. All rights reserved.