简体   繁体   English

Spring Integration java.lang.IllegalArgumentException:发现模棱两可的参数类型

[英]Spring Integration java.lang.IllegalArgumentException: Found ambiguous parameter type

I received the following error when trying to send a request to an http outbound gateway. 尝试将请求发送到http出站网关时,我收到以下错误。 After getting the response, I am converting the json payload to a list of objects from other posts I have read it could be a problem with the service activator or the transformer. 收到响应后,我将json负载转换为其他我读过的帖子的对象列表,这可能是服务激活器或转换器的问题。 I am still trying to get a handle on EIP and SI. 我仍在尝试了解EIP和SI。

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpPostAtms' defined in class path resource [com/backbase/atm/config/InfrastructorConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'httpPostAtms' threw exception; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [class java.lang.Object] for method match: [public default java.util.stream.Stream java.util.Collection.parallelStream(), public void java.util.Arrays$ArrayList.forEach(java.util.function.Consumer), public void java.util.Arrays$ArrayList.sort(java.util.Comparator), public boolean java.util.AbstractCollection.remove(java.lang.Object), public java.util.ListIterator java.util.AbstractList.listIterator(int), public java.lang.Object[] java.util.Arrays$ArrayList.toArray(java.lang.Object[]), public default boolean java.util.Collection.removeIf(java.util.function.Predicate), public boolean java.util.AbstractCollection.retainAll(java.util.Collection), public void java.util.Arrays$ArrayList.replaceAll(java.util.function.UnaryOperator)]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
    at com.backbase.atm.IngAtmApplication.main(IngAtmApplication.java:23) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'httpPostAtms' threw exception; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [class java.lang.Object] for method match: [public default java.util.stream.Stream java.util.Collection.parallelStream(), public void java.util.Arrays$ArrayList.forEach(java.util.function.Consumer), public void java.util.Arrays$ArrayList.sort(java.util.Comparator), public boolean java.util.AbstractCollection.remove(java.lang.Object), public java.util.ListIterator java.util.AbstractList.listIterator(int), public java.lang.Object[] java.util.Arrays$ArrayList.toArray(java.lang.Object[]), public default boolean java.util.Collection.removeIf(java.util.function.Predicate), public boolean java.util.AbstractCollection.retainAll(java.util.Collection), public void java.util.Arrays$ArrayList.replaceAll(java.util.function.UnaryOperator)]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    ... 18 common frames omitted
Caused by: java.lang.IllegalArgumentException: Found ambiguous parameter type [class java.lang.Object] for method match: [public default java.util.stream.Stream java.util.Collection.parallelStream(), public void java.util.Arrays$ArrayList.forEach(java.util.function.Consumer), public void java.util.Arrays$ArrayList.sort(java.util.Comparator), public boolean java.util.AbstractCollection.remove(java.lang.Object), public java.util.ListIterator java.util.AbstractList.listIterator(int), public java.lang.Object[] java.util.Arrays$ArrayList.toArray(java.lang.Object[]), public default boolean java.util.Collection.removeIf(java.util.function.Predicate), public boolean java.util.AbstractCollection.retainAll(java.util.Collection), public void java.util.Arrays$ArrayList.replaceAll(java.util.function.UnaryOperator)]
    at org.springframework.util.Assert.isNull(Assert.java:113) ~[spring-core-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.findHandlerMethodsForTarget(MessagingMethodInvokerHelper.java:499) ~[spring-integration-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:226) ~[spring-integration-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:149) ~[spring-integration-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:144) ~[spring-integration-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.integration.handler.MethodInvokingMessageProcessor.<init>(MethodInvokingMessageProcessor.java:60) ~[spring-integration-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.integration.transformer.MethodInvokingTransformer.<init>(MethodInvokingTransformer.java:47) ~[spring-integration-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.integration.dsl.IntegrationFlowDefinition.transform(IntegrationFlowDefinition.java:516) ~[spring-integration-java-dsl-1.2.2.RELEASE.jar:na]
    at org.springframework.integration.dsl.IntegrationFlowDefinition.transform(IntegrationFlowDefinition.java:496) ~[spring-integration-java-dsl-1.2.2.RELEASE.jar:na]
    at org.springframework.integration.dsl.IntegrationFlowDefinition.transform(IntegrationFlowDefinition.java:483) ~[spring-integration-java-dsl-1.2.2.RELEASE.jar:na]
    at com.backbase.atm.config.InfrastructorConfig.httpPostAtms(InfrastructorConfig.java:50) ~[classes/:na]
    at com.backbase.atm.config.InfrastructorConfig$$EnhancerBySpringCGLIB$$154e5ed2.CGLIB$httpPostAtms$1(<generated>) ~[classes/:na]
    at com.backbase.atm.config.InfrastructorConfig$$EnhancerBySpringCGLIB$$154e5ed2$$FastClassBySpringCGLIB$$30080451.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at com.backbase.atm.config.InfrastructorConfig$$EnhancerBySpringCGLIB$$154e5ed2.httpPostAtms(<generated>) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    ... 19 common frames omitted

my config 我的配置

    package com.backbase.atm.config;

import java.util.Arrays;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.dsl.core.Pollers;
import org.springframework.integration.dsl.http.Http;
import org.springframework.integration.dsl.support.Transformers;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.messaging.MessageChannel;

import com.backbase.atm.model.Atm;



@IntegrationComponentScan
@Configuration
@EnableIntegration
@ComponentScan
public class InfrastructorConfig {

    @Bean
    public MessageChannel requestChannel() {
        return new DirectChannel() ;
    }

    @Bean(name = PollerMetadata.DEFAULT_POLLER)
    public PollerMetadata poller() {
        return Pollers.fixedRate(500).get();
    }

    @Bean
    public IntegrationFlow httpPostAtms() {

        return IntegrationFlows.from("requestChannel")
                .handle(Http.outboundGateway("https://www.ing.nl/api/locator/atms/")
                        .httpMethod(HttpMethod.GET)
                        .expectedResponseType(String.class))
                .<String, String>transform(p -> p.substring(5))
                .transform(Arrays.asList(Transformers.fromJson(Atm[].class)))
                .channel("responseChannel")
                .get();

    }

}

my gateway 我的网关

package com.backbase.atm.service;

import java.util.List;

import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.messaging.handler.annotation.Payload;

import com.backbase.atm.model.Atm;

@MessagingGateway
public interface IntegrationService {

    @Gateway(requestChannel = "requestChannel")
    @Payload("'string'")
    List<Atm> getAllAtms();
}

the object that I am trying to convert the payload to 我尝试将有效负载转换为的对象

 package com.backbase.atm.model;

public class Atm {

    private Address address;
    String distance;
    String type;

    public Atm() {
        super();
    }

    public Atm(Address address) {
        setAddress(address);
    }



    public Atm(Address address, String distance, String type) {
        super();
        this.address = address;
        this.distance = distance;
        this.type = type;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getDistance() {
        return distance;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("Atm: address=").append(address).append(", distance=").append(distance).append(", type=")
                .append(type).append("");
        return builder.toString();
    }
}

sample payload response 样本有效载荷响应

[{"address":{"street":"Molenwerf","housenumber":"20","postalcode":"1541 WR","city":"Koog aan de Zaan","geoLocation":{"lat":"52.457912","lng":"4.799866"}},"distance":0,"type":"ING"}]

You have suspicious code: 您有可疑的代码:

.transform(Arrays.asList(Transformers.fromJson(Atm[].class)))

What drives you to use Arrays.asList() there? 是什么促使您在那里使用Arrays.asList()

You use Transformers.fromJson() which is just a factory and returns for you valid Transformer object. 您使用Transformers.fromJson()只是一个工厂,并为您返回有效的Transformer对象。 The .transform() can simply deal with that one. .transform()可以简单地处理那个。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 春季-java.lang.IllegalArgumentException - Spring - java.lang.IllegalArgumentException java.lang.IllegalArgumentException:找到了多个参数类型候选:[java.lang.String]和[java.lang.Long] - java.lang.IllegalArgumentException: Found more than one parameter type candidate: [java.lang.String] and [java.lang.Long] 春季-AWS(无春季启动):java.lang.IllegalArgumentException:不是托管类型 - Spring - AWS (no spring boot): java.lang.IllegalArgumentException: Not a managed type 错误:java.lang.IllegalArgumentException:发现意外的类型标记 67 - Error:java.lang.IllegalArgumentException: Unexpected type tag 67 found java.lang.IllegalArgumentException:找不到类型返回值的转换器 - java.lang.IllegalArgumentException: No converter found for return value of type java.lang.IllegalArgumentException:在Spring Boot应用程序中不是托管类型 - java.lang.IllegalArgumentException: Not a managed type in spring boot app spring-data-solr java.lang.IllegalArgumentException:不是托管类型 - spring-data-solr java.lang.IllegalArgumentException: Not a managed type java.lang.IllegalArgumentException:Spring Controller中的参数类型不匹配 - java.lang.IllegalArgumentException: argument type mismatch in Spring Controller java.lang.IllegalArgumentException:不是托管类型 - Spring Boot 中的多个数据库 - java.lang.IllegalArgumentException: Not a managed type - Multiple Databases in Spring Boot Spring Boot 异常“java.lang.IllegalArgumentException:不是托管类型:” - Spring Boot exception "java.lang.IllegalArgumentException: Not a managed type:"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM