org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'axonJsonSerializer' defined in class path resource [com/Ultimatesoftware/IntegrationServices/Commands/config/AxonConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.serialization.Serializer]: Factory method 'axonJsonSerializer' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/datatype/jsr310/JSR310Module
@Configuration
public class AxonConfig {
@Value("${mongodb.url}")
private String mongoUrl;
@Value("${mongodb.port}")
private int mongoPort;
@Value("${mongodb.dbname}")
private String mongoDbName;
@Value("${mongodb.events.collection.name}")
private String eventsCollectionName;
@Value("${mongodb.events.snapshot.collection.name}")
private String snapshotCollectionName;
@Bean
public Serializer axonJsonSerializer() {
return new JacksonSerializer();
}
@Bean
public EventStorageEngine eventStorageEngine(){
return new MongoEventStorageEngine(
axonJsonSerializer(),null, axonMongoTemplate(), new DocumentPerEventStorageStrategy());
}
@Bean(name = "axonMongoTemplate")
public MongoTemplate axonMongoTemplate() {
MongoTemplate template = new DefaultMongoTemplate(mongoClient(), mongoDbName, eventsCollectionName, snapshotCollectionName);
return template;
}
@Bean
public MongoClient mongoClient(){
MongoFactory mongoFactory = new MongoFactory();
mongoFactory.setMongoAddresses(Arrays.asList(new ServerAddress(mongoUrl)));
return mongoFactory.createMongo();
}
}
and here is the code I have in the main application file:
@SpringBootApplication
public class CommandsApplication {
public static void main(String[] args) {
SpringApplication.run(CommandsApplication.class, args);
}
@Bean
public Exchange exchange() { return ExchangeBuilder.fanoutExchange("Integration").build(); }
@Bean
public Queue queue() { return QueueBuilder.durable("Integration").build(); }
@Bean
public Binding binding(){ return BindingBuilder.bind(queue()).to(exchange()).with("*").noargs(); }
@Autowired
public void configure(AmqpAdmin admin){
admin.declareExchange(exchange());
admin.declareQueue(queue());
admin.declareBinding(binding());
}
}
Frans van Buul
AxonIQ - https://axoniq.io
+31 6 5068 2984
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframework+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.3.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_131]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_131]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_131]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_131]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_131]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_131]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:57) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongodb-driver-core-3.4.3.jar:na]
... 3 common frames omitted
2017-10-15 05:55:52.585 WARN 12432 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventStorageEngine': Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.99.100:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
2017-10-15 05:55:52.602 INFO 12432 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-10-15 05:55:52.622 INFO 12432 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-10-15 05:55:52.628 ERROR 12432 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eventStorageEngine': Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.99.100:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
at com.Ultimatesoftware.IntegrationServices.Commands.CommandsApplication.main(CommandsApplication.java:14) [classes/:na]
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.99.100:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:377) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:104) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:415) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:144) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.operation.CreateIndexesOperation.execute(CreateIndexesOperation.java:71) ~[mongodb-driver-core-3.4.3.jar:na]
at com.mongodb.Mongo.execute(Mongo.java:845) ~[mongodb-driver-3.4.3.jar:na]
at com.mongodb.Mongo$2.execute(Mongo.java:828) ~[mongodb-driver-3.4.3.jar:na]
at com.mongodb.MongoCollectionImpl.createIndexes(MongoCollectionImpl.java:491) ~[mongodb-driver-3.4.3.jar:na]
at com.mongodb.MongoCollectionImpl.createIndex(MongoCollectionImpl.java:458) ~[mongodb-driver-3.4.3.jar:na]
at org.axonframework.mongo.eventsourcing.eventstore.AbstractMongoEventStorageStrategy.ensureIndexes(AbstractMongoEventStorageStrategy.java:200) ~[axon-mongo-3.0.6.jar:3.0.6]
at org.axonframework.mongo.eventsourcing.eventstore.MongoEventStorageEngine.ensureIndexes(MongoEventStorageEngine.java:123) ~[axon-mongo-3.0.6.jar:3.0.6]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134) ~[spring-beans-4.3.11.RELEASE.jar:4.3.11.RELEASE]
... 18 common frames omitted
Enter code here...
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
Frans van Buul
AxonIQ - https://axoniq.io
+31 6 5068 2984
To unsubscribe from this group and stop receiving emails from it, send an email to axonframework+unsubscribe@googlegroups.com.
Hello Frans,
@SpringBootApplication
public class QueriesApplication {
public static void main(String[] args) {
SpringApplication.run(QueriesApplication.class, args);
}
@Bean
public SpringAMQPMessageSource IntegrationsQueue(Serializer serializer){
return new SpringAMQPMessageSource(new DefaultAMQPMessageConverter(serializer)){
@RabbitListener(queues = "Integration")
@Override
public void onMessage(Message message, Channel channel) throws Exception{
super.onMessage(message, channel);
}
};
}
}
controller class:
@ProcessingGroup("Integration")
@RestController
@RequestMapping(value = "/integrationQueries")
public class IntegrationQueryController {
private final CommandGateway commandGateway;
private final IntegrationRepository integrationRepository;
public IntegrationQueryController(CommandGateway commandGateway, IntegrationRepository integrationRepository){
this.commandGateway = commandGateway;
this.integrationRepository = integrationRepository;
}
@GetMapping
public Iterable<IntegrationEntity> all() { return integrationRepository.findAll(); }
}
entity listner class:
@Component
public class IntegrationEntityListener {
private IntegrationRepository repository;
@Autowired
public IntegrationEntityListener(IntegrationRepository repository){
this.repository = repository;
}
@EventHandler
public void on(IntegrationCreatedEvent event){
repository.save(new IntegrationEntity(event.getIntegrationId(), event.getIntegrationName(), event.getPartner()));
}
}Repository class
@Repository
public interface IntegrationRepository extends MongoRepository<IntegrationEntity, String> {
public List<IntegrationEntity> findByPartner(String partner);
public List<IntegrationEntity> findByTenantId(String tenantId);
public List<IntegrationEntity> findByTenantIdAndPartner(String tenantId, String partner);
}and application.properties
axon.eventhandling.processors.Integration.source=IntegrationsQueue
server.port=8081
spring.rabbitmq.addresses=192.168.99.100:5672
# mongo
mongodb.url=192.168.99.100
mongodb.port=32784
# mongodb.username=
# mongodb.password=
mongodb.dbname=Integrations
mongodb.events.collection.name=events
mongodb.events.snapshot.collection.name=snapshots
AxonIQ - https://axoniq.io
+31 6 5068 2984
o.a.a.e.spring.SpringAMQPMessageSource : Unable to deserialize an incoming message. Ignoring it. org.axonframework.serialization.UnknownSerializedTypeException: Could not deserialize a message. The serialized type is unknown: com.Ultimatesoftware.IntegrationServices.Commands.Api.IntegrationCreatedEvent (rev. null)
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
2017-10-15 13:34:10.719 ERROR 26924 --- [cTaskExecutor-1] o.a.eventhandling.LoggingErrorHandler : EventListener [IntegrationEntityListener] failed to handle event [047823bb-1e44-4348-a30f-3950d31b5053] (com.Ultimatesoftware.Integrationservices.Api.IntegrationCreatedEvent). Continuing processing with next listener
Caused by: org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1)
at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1519) ~[xpp3-1.1.4c.jar:na]
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395) ~[xpp3-1.1.4c.jar:na]
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093) ~[xpp3-1.1.4c.jar:na]
at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109) ~[xstream-1.4.9.jar:1.4.9]
... 52 common frames omitted
Frans van Buul
AxonIQ - https://axoniq.io
+31 6 5068 2984
To unsubscribe from this group and stop receiving emails from it, send an email to axonframework+unsubscribe@googlegroups.com.