3.0M4 EnableAxonAutoConfiguration issue

136 views
Skip to first unread message

Wim Wintmolders

unread,
Sep 10, 2016, 11:20:29 AM9/10/16
to Axon Framework Users
Hi, 

found an issue with @EnableAxonAutoConfiguration. For beans that have event handlers and use constructor injection with component scanning, an exception is thrown.

It is easy to reproduce. I created a spring boot app with jpa, web, hsqldb and lombok and then added the following code.

package com.example;

import org.axonframework.spring.config.EnableAxonAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan
@EnableAxonAutoConfiguration
public class DemoApplication {

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

package com.example;

import org.springframework.stereotype.Component;

import javax.persistence.EntityManager;

@Component
public class SampleBean {

public SampleBean(EntityManager em) {
System.out.println("--->" + em);
}

//@EventHandler uncomment this to break app
public void on(String event) {

}
}

Uncommenting @EventHandler gives the following error 

Caused by: java.lang.NoSuchMethodException: com.example.SampleBean.<init>()


Is this a bug or should I use another Configuration setup?

Allard Buijze

unread,
Sep 11, 2016, 4:26:47 PM9/11/16
to Axon Framework Users
Hi Wim,

thanks for reporting! It appears to be a timing issue in the AxonAutoConfiguration.
Will provide a fix soon.

Cheers,

Allard


--
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 axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dominic Heutelbeck

unread,
Sep 14, 2016, 6:11:27 AM9/14/16
to Axon Framework Users
Hello, Allard.

First off, thanks for the weminar. The trick using Kotlin for API definition is solving one of my major gripes I had.

I may have found another issue with the @EnableAxonAutoConfiguration. Ther appears to be some kind of interference with the useage of mongodb.

When I add the annotation to my configuration, MongoClient cannot longer be autowired. When I remove it, it works just fine, but I have to manually wire the command handlers for my aggregates.

Thanks a lot.
Dominic

Example:

@Configuration
@EnableAxonAutoConfiguration
public class AxonConfiguration {

@Autowired
private MongoClient mongoClient;

@Bean
EventStorageEngine eventStorageEngine() {
return new MongoEventStorageEngine(new DefaultMongoTemplate(mongoClient));

Allard Buijze

unread,
Sep 28, 2016, 2:41:28 PM9/28/16
to Axon Framework Users
Hi,

I have managed to reproduce and fix issue. It will be part of the next release. Thanks for reporting it in detail.

The issue was with the timing at which the Axon component would wire things up. That was done a bit too early, so these components couldn't be autowired yet.

Cheers,

Allard
Op wo 14 sep. 2016 om 12:11 schreef Dominic Heutelbeck <dominic.h...@gmail.com>

Dominic Heutelbeck

unread,
Oct 3, 2016, 6:01:15 PM10/3/16
to Axon Framework Users
Great news. This will eliminate a lot of boilerplate configuration. Looking forward to it.
Thanks a lot.
Dominic
Reply all
Reply to author
Forward
0 new messages