Trouble configuring AxonDB

I have a working spring boot axon 3.2 application and I am having difficulty converting the event store from postgres to axondb. I have read to documentation and have studied the spring boot auto-configuration example referenced in the documentation (https://github.com/AxonIQ/axoniq-eventstore-client/tree/master/examples/axondb-client-example) but I’m getting the following exception when I try to start my application.

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) at com.myco.Recover.main(Recover.java:10) 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:498) at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:413) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ... 13 common frames omitted Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'callingAgentContextFilter' defined in file [/home/troyh/fx/repos/recover/pkg-rest/target/classes/com/fedexx/pkg/rest/CallingAgentContextFilter.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'agentRepository' defined in class path resource [com/fedexx/pkg/command/AgentConfig.class]: Unsatisfied dependency expressed through method 'agentRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventBus' defined in class path resource [com/fedexx/AxonConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/axonframework/serialization/Serializer" at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1276) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1133) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:226) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:182) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:177) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:159) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:81) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:250) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:237) at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'agentRepository' defined in class path resource [com/fedexx/pkg/command/AgentConfig.class]: Unsatisfied dependency expressed through method 'agentRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventBus' defined in class path resource [com/fedexx/AxonConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/axonframework/serialization/Serializer" at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:474) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1256) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1105) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ... 25 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventBus' defined in class path resource [com/fedexx/AxonConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/axonframework/serialization/Serializer" at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1256) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1105) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ... 39 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.eventsourcing.eventstore.EventStore]: Factory method 'eventStore' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/axonframework/serialization/Serializer" at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582) ... 52 common frames omitted Caused by: java.lang.BootstrapMethodError: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/axonframework/serialization/Serializer" at org.axonframework.eventsourcing.eventstore.AbstractEventStorageEngine.<init>(AbstractEventStorageEngine.java:83) at org.axonframework.eventsourcing.eventstore.AbstractEventStorageEngine.<init>(AbstractEventStorageEngine.java:63) at io.axoniq.axondb.client.axon.AxonDBEventStore$AxonIQEventStorageEngine.<init>(AxonDBEventStore.java:111) at io.axoniq.axondb.client.axon.AxonDBEventStore$AxonIQEventStorageEngine.<init>(AxonDBEventStore.java:97) at io.axoniq.axondb.client.axon.AxonDBEventStore.<init>(AxonDBEventStore.java:79) at io.axoniq.axondb.client.axon.AxonDBEventStore.<init>(AxonDBEventStore.java:66) at com.myco.AxonConfig.eventStore(AxonConfig.java:92) at com.fedexx.AxonConfig$$EnhancerBySpringCGLIB$$ef6f3013.CGLIB$eventStore$5(<generated>) at com.fedexx.AxonConfig$$EnhancerBySpringCGLIB$$ef6f3013$$FastClassBySpringCGLIB$$5dc94d10.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) at com.fedexx.AxonConfig$$EnhancerBySpringCGLIB$$ef6f3013.eventStore(<generated>) 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:498) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ... 53 common frames omitted Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/axonframework/serialization/Serializer" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 70 common frames omitted

Below is my base axon configuration (everything except aggregate repository configurations):

`
package com.fedexx;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import org.axonframework.commandhandling.AsynchronousCommandBus;
import org.axonframework.common.caching.Cache;
import org.axonframework.common.caching.WeakReferenceCache;
import org.axonframework.common.transaction.TransactionManager;
import org.axonframework.config.EventHandlingConfiguration;
import org.axonframework.eventsourcing.eventstore.EventStore;
import org.axonframework.messaging.Message;
import org.axonframework.messaging.annotation.ParameterResolverFactory;
import org.axonframework.messaging.interceptors.BeanValidationInterceptor;
import org.axonframework.messaging.interceptors.TransactionManagingInterceptor;
import org.axonframework.serialization.Serializer;
import org.axonframework.serialization.json.JacksonSerializer;
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.axoniq.axondb.client.AxonDBConfiguration;
import io.axoniq.axondb.client.axon.AxonDBEventStore;

@Configuration
public class AxonConfig {

public static final String EXCHANGE_NAME = “FXEvents”;
public static final String QUEUE_NAME = EXCHANGE_NAME;

@Bean
public Serializer eventSerializer() {
return new JacksonSerializer();
}

@Bean
public BeanValidationInterceptor<Message<?>> beanValidationInteceptor() {
return new BeanValidationInterceptor<>();
}

@Bean(destroyMethod = “shutdown”)
public AsynchronousCommandBus commandBus(TransactionManager transactionManager) {
AsynchronousCommandBus cb = new AsynchronousCommandBus();
cb.registerDispatchInterceptor(beanValidationInteceptor());
cb.registerHandlerInterceptor(new TransactionManagingInterceptor<>(transactionManager));
return cb;
}

@Bean
public Cache cache() {
return new WeakReferenceCache();
}

@Bean
public SpringAggregateSnapshotter snapshotter(ParameterResolverFactory parameterResolverFactory,
EventStore eventStore, TransactionManager transactionManager) {
Executor executor = Executors.newSingleThreadExecutor();
SpringAggregateSnapshotter snapshotter =
new SpringAggregateSnapshotter(eventStore, parameterResolverFactory, executor, transactionManager);
return snapshotter;
}

@Bean(name = “eventBus”)
public EventStore eventStore(AxonDBConfiguration axonDBConfiguration, Serializer eventSerializer) {
return new AxonDBEventStore(axonDBConfiguration, eventSerializer);
}

@Bean
public AxonDBConfiguration axonDBConfiguration() {
return new AxonDBConfiguration();
}
}
`

Any help is greatly appreciated!

Thanks,

Troy

This seems to class loading related. Just set your WebSphere classloading strategy to ‘Parent Last’ :wink:

But now back to 2018:
Are you using Spring Boot DevTools?
Do you happen to have two different versions of an Axon (or related) library on the classpath?

Cheers,

Allard

Thanks for the reply Allard! Spring boot is certainly a breath of fresh air when compared to the app server deployment days of old…at least most of the time.

I am using Spring Boot DevTools and I don’t have conflicting versions of axon. I have a maven multi-module project with the following dependency management declaration (and all dependency declarations from any of axon modules use the managed version):

<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.axonframework</groupId> <artifactId>axon-core</artifactId> <version>${axon.version}</version> </dependency> <dependency> <groupId>org.axonframework</groupId> <artifactId>axon-spring</artifactId> <version>${axon.version}</version> </dependency> <dependency> <groupId>org.axonframework</groupId> <artifactId>axon-test</artifactId> <scope>test</scope> <version>${axon.version}</version> </dependency> </dependencies> </dependencyManagement>

I did remove the DevTools dependency from the project and the application started up (the serializer issue was solved). However, now there’s an issue resolving the location of the axondb back end, but only in specific deployment scenarios.

So, the first issue, DevTools. What can be done to enable the use of this spring boot feature?

The second issue, resolving the location of the back end is related to the fact that I am deploying axondb in a docker container. When I also deploy my spring boot application in a docker container everything comes up and works as expected. However, when I try to deploy the spring boot application on localhost (i.e. the development use case; launching from STS Spring Boot Dashboard) then it fails. I get the following exception when my data loaders run at startup because they can’t find the host “axondb”:

java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:781) at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) at com.fedexx.Recover.main(Recover.java:10) Caused by: org.axonframework.eventsourcing.eventstore.EventStoreException: UNAVAILABLE at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at io.axoniq.axondb.client.axon.AxonErrorMapping.convert(AxonErrorMapping.java:72) at io.axoniq.axondb.client.AppendEventTransaction.commit(AppendEventTransaction.java:53) at io.axoniq.axondb.client.axon.AxonDBEventStore$AxonIQEventStorageEngine.lambda$null$1(AxonDBEventStore.java:125) at org.axonframework.messaging.unitofwork.MessageProcessingContext.notifyHandlers(MessageProcessingContext.java:68) at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.notifyHandlers(DefaultUnitOfWork.java:91) at org.axonframework.messaging.unitofwork.AbstractUnitOfWork.changePhase(AbstractUnitOfWork.java:221) at org.axonframework.messaging.unitofwork.AbstractUnitOfWork.commitAsRoot(AbstractUnitOfWork.java:82) at org.axonframework.messaging.unitofwork.AbstractUnitOfWork.commit(AbstractUnitOfWork.java:70) at org.axonframework.messaging.unitofwork.DefaultUnitOfWork.executeWithResult(DefaultUnitOfWork.java:80) at org.axonframework.commandhandling.SimpleCommandBus.handle(SimpleCommandBus.java:156) at org.axonframework.commandhandling.AsynchronousCommandBus.lambda$handle$1(AsynchronousCommandBus.java:83) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE at io.grpc.Status.asRuntimeException(Status.java:526) at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:385) at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41) at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:339) at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:443) at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:525) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:446) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:557) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:107) ... 3 common frames omitted Caused by: java.net.UnknownHostException: axondb: Name or service not known at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) at java.net.InetAddress.getAllByName0(InetAddress.java:1276) at java.net.InetAddress.getAllByName(InetAddress.java:1192) at java.net.InetAddress.getAllByName(InetAddress.java:1126) at io.grpc.internal.DnsNameResolver$JdkResolver.resolve(DnsNameResolver.java:325) at io.grpc.internal.DnsNameResolver$1.run(DnsNameResolver.java:156) ... 3 common frames omitted

The thing about this that doesn’t make any sense is the fact that my default spring boot profile has the following (yaml) configuration:

axoniq: axondb: servers: localhost:8123

When I run my spring boot application in the container I run with an active profile that has the following overriding axoniq configuration:

axoniq: axondb: servers: axondb:8123

FYI, I am using axondb-client-1.2.1.jar

Troy

Hi Troy,

we’ll look into the devtools issue. Fixing is usually simple, as soon as we have managed to reproduce the problem. And that’s the hard part. Will keep you posted.

Meanwhile, your connection-through-docker issue is probably cause by an incorrect “hostname” in AxonDB.
The way the client works, is that it connects using the configured URL. In that connection, it will request the actual host to use for the connection towards the database. This has to do with clustering. Clients need to connect to the master to be able to store events. The initial step is to return the hostname of that master.
It seems that your axondb instance returns “axondb” as the host name. The client then tries to connect to that, and doesn’t get a connection.

The solution would be to configure the hostname of the container (see https://docs.docker.com/v17.09/engine/userguide/networking/default_network/configure-dns/) and/or ensuring that the host knows how to route connections to that host (e.g. in /etc/hosts or c:\Windows\System32\drivers\etc\hosts).
I will also discuss with the team if there is anything we can do to simplify this process.

Cheers,

Allard

Hi Allard,

For what it’s worth, we are presently using docker compose to deploy all the services. By default docker compose sets up private networking for all services where each service gets a hostname consistent with the declared docker compose service name.

Below is my docker-compose.yml:

`

version: ‘3’

services:

mongodb:
image: mongo:3.0.4
hostname: mongodb
command: mongod --smallfiles
ports:

  • “${MONGO_PORT}:27017”

postgresdb:
image: postgres:9.4
ports:

  • “${POSTGRES_PORT}:5432”
    volumes:
  • postgresvol:/var/lib/postgresql/fxrecover
    environment:
  • POSTGRES_USER=fxpostgres
  • POSTGRES_PASSWORD=supersecret

axonhub:
image: fx-axon-hub:1.0.2
ports:

  • “8024:8024”
  • “8124:8124”
    depends_on:
  • axondb

axondb:
image: fx-axon-db:1.2.2
ports:

  • “8023:8023”
  • “8123:8123”

recover-app:
image: ${RECOVER_IMAGE_ID}:${RECOVER_IMAGE_TAG}
environment:

  • SPRING_PROFILES_ACTIVE=docker,dev
    ports:
  • “${RECOVER_PORT}:8080”
    depends_on:
  • axondb
  • postgresdb
  • mongodb
    command: java -jar /app.jar

recover-ui:
image: ${RECOVER_UI_IMAGE_ID}:${RECOVER_UI_IMAGE_TAG}
ports:

  • “${RECOVER_UI_PORT}:80”
    volumes:
  • ./recover-ui/src/assets/env-cfg.json:/usr/share/nginx/html/assets/env-cfg.json
    depends_on:
  • recover-app

volumes:
postgresvol:

`

To be clear, there is no issue when I bring up all the services declared in the docker-compose.yml file together. This approach is not conducive to iterative development though. For this scenario we want to deploy all the infrastructure services via docker-compose but we want to deploy the application services (recover-app and recover-ui) in the IDE–STS Spring Boot Dashboard and angular cli respectively.

I used your suggestion about /etc/hosts to solve the issue for the development usecase. I simply added a rule to redirect the host “axondb” to “127.0.0.1”. THANKS!!!

This solution is not ideal, however, because every developer will need to manage /etc/hosts. I think I can see some of the complexity related to axon-client needing to be configured to talk to the master node, which potentially changes over time. I’m assuming this means the axon-client will be re-configured as needed during its life cycle. Can you explain at little about what that looks like?

Thanks!

Troy

Hi Troy,

Wanted to get back to you about this:

“This solution is not ideal, however, because every developer will need to manage /etc/hosts. I think I can see some of the complexity related to axon-client needing to be configured to talk to the master node, which potentially changes over time. I’m assuming this means the axon-client will be re-configured as needed during its life cycle. Can you explain at little about what that looks like?”

Without going into too much detail, the outline is this: the client connects to an arbitrary node within the set of nodes that is knows. It may be that it’s connecting to the master - if so, all is good. If the node it is connecting to doesn’t happen to be the master, if will send a message to the client to redirect it to the node that is actually the master. For this mechanism to work, the nodes must know under which name clients can reach them.

The network name of the node is managed by two properties in axonhub.properties (and similarly for db):

Hostname of this node as communicated to clients, defaults to the result of hostname command

axoniq.axonhub.hostname=

Domain of this node as communicated to clients. Optional, if set will be appended to the hostname in communication with clients.

axoniq.axonhub.domain=

You can use this to avoid the need to change /etc/hosts. If you set ‘axoniq.axonhub.hostname’ to ‘localhost’, you would be able to successfully connect to axonhub using ‘localhost’.

Kind regards,

Thanks for the explanation Frans!