Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

springwolf-amqp-example fails #892

Closed
hirth-abi opened this issue Aug 2, 2024 · 3 comments
Closed

springwolf-amqp-example fails #892

hirth-abi opened this issue Aug 2, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@hirth-abi
Copy link

Describe the bug

When I try to run the springwolf-amqp-example as described in the README it fails with amqp: nodename nor servname provided, or not known

Dependencies and versions used

Current master branch.

Code example

cd springwolf-core && ./gradlew build -p springwolf-examples/springwolf-amqp-example bootRun

Stack trace and error logs

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitMqReadinessVerifier' defined in file [/Users/GUCSVEH/Projekte/springwolf-core/springwolf-examples/springwolf-amqp-example/build/classes/java/main/io/github/springwolf/examples/amqp/configuration/RabbitMqReadinessVerifier.class]: Failed to instantiate [io.github.springwolf.examples.amqp.configuration.RabbitMqReadinessVerifier$$SpringCGLIB$$0]: Constructor threw exception
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:318) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:306) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1375) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1212) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971) ~[spring-context-6.1.11.jar:6.1.11]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625) ~[spring-context-6.1.11.jar:6.1.11]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.2.jar:3.3.2]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.2.jar:3.3.2]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.2.jar:3.3.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.2.jar:3.3.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.2.jar:3.3.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.2.jar:3.3.2]
        at io.github.springwolf.examples.amqp.SpringwolfAmqpExampleApplication.main(SpringwolfAmqpExampleApplication.java:11) ~[main/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.github.springwolf.examples.amqp.configuration.RabbitMqReadinessVerifier$$SpringCGLIB$$0]: Constructor threw exception
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:221) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117) ~[spring-beans-6.1.11.jar:6.1.11]
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315) ~[spring-beans-6.1.11.jar:6.1.11]
        ... 19 common frames omitted
Caused by: org.springframework.amqp.AmqpIOException: java.net.UnknownHostException: amqp: nodename nor servname provided, or not known
        at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:70) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:622) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:726) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:257) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2249) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2222) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2202) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at io.github.springwolf.examples.amqp.configuration.RabbitMqReadinessVerifier.verifyRabbitMqIsUp(RabbitMqReadinessVerifier.java:33) ~[main/:na]
        at io.github.springwolf.examples.amqp.configuration.RabbitMqReadinessVerifier.<init>(RabbitMqReadinessVerifier.java:22) ~[main/:na]
        at io.github.springwolf.examples.amqp.configuration.RabbitMqReadinessVerifier$$SpringCGLIB$$0.<init>(<generated>) ~[main/:na]
        at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[na:na]
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[na:na]
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[na:na]
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:208) ~[spring-beans-6.1.11.jar:6.1.11]
        ... 21 common frames omitted
Caused by: java.net.UnknownHostException: amqp: nodename nor servname provided, or not known
        at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:na]
        at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:52) ~[na:na]
        at java.base/java.net.InetAddress$PlatformResolver.lookupByName(InetAddress.java:1211) ~[na:na]
        at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1828) ~[na:na]
        at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:1139) ~[na:na]
        at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1818) ~[na:na]
        at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1688) ~[na:na]
        at com.rabbitmq.client.DnsRecordIpAddressResolver.resolveIpAddresses(DnsRecordIpAddressResolver.java:83) ~[amqp-client-5.21.0.jar:5.21.0]
        at com.rabbitmq.client.DnsRecordIpAddressResolver.getAddresses(DnsRecordIpAddressResolver.java:73) ~[amqp-client-5.21.0.jar:5.21.0]
        at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1245) ~[amqp-client-5.21.0.jar:5.21.0]
        at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1198) ~[amqp-client-5.21.0.jar:5.21.0]
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connectAddresses(AbstractConnectionFactory.java:668) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:637) ~[spring-rabbit-3.1.6.jar:3.1.6]
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:584) ~[spring-rabbit-3.1.6.jar:3.1.6]
        ... 33 common frames omitted
@hirth-abi hirth-abi added the bug Something isn't working label Aug 2, 2024
@timonback
Copy link
Member

Hi @hirth-abi ,

looks like amqp is not running, or the hostname does not match.
Have you tried starting the docker-compose amqp service and updated the spring.rabbit.host in application.properties to localhost?

I do notice a gap in the readme explaining this step. In #886 the default values are updated so that only amqp must be started

@hirth-abi
Copy link
Author

Ah yes, since it was not mentioned in the readme, I haven't started it. So it works 👍

But maybe activate the Spring Boot Docker Compose integration to start it automatically? It's one line and worked out of the box for me (2c3cd54)

@timonback
Copy link
Member

Great. Unfortunately, the docker-compose setup is also tied to the integration tests.
And test containers throws an error, when containers are already running (which are automatically started by spring boot docker compose starter).

Therefore, I opted for the manual approach and updated the docs -> #894

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants