Annotation cluster selector and cglib

Hi Allard,

We’re trying to setup Axon clusters and add event listeners to the cluster using the annotation cluster selector. However we run into the problem that classes that are proxied using cglib are not added to a cluster. Hence, the application context cannot be started. Please see the stack trace below for extra information.

Stacktrace:

Onegini logo small signature[18].png

Hi Stein,

I don’t think it’s a CGLib problem. This is just an error you get when there is an event listener that cannot be assigned to a cluster. The cluster selector normally looks at the class of the actual bean (the Cglib proxy implements EventListenerProxy, so the class that is being proxies is checked for annotations, classname, etc).
Make sure the criteria you have configured in your spring context are complete.

You can also set a cluster as “default”. In that case, all listeners not assigned to a cluster will be assigned to the default one.

Cheers,

Allard

Onegini logo small signature[18].png

Hi Stein,

I don’t think it’s a CGLib problem. This is just an error you get when there is an event listener that cannot be assigned to a cluster. The cluster selector normally looks at the class of the actual bean (the Cglib proxy implements EventListenerProxy, so the class that is being proxies is checked for annotations, classname, etc).
Make sure the criteria you have configured in your spring context are complete.

The Dao’s which don’t work with the annotation selector are JpaRepositories (the classes are also annotated with the @Repository annotation (spring). I’m just curious because other classes annotated with the same cluster selector do work just fine… Only the dao’s fail.

When I use other criteria (e.g. the class-name criterium it works fine. I just liked the annotation approach because no classname mappings need to be configured in the spring configuration.)

You can also set a cluster as “default”. In that case, all listeners not assigned to a cluster will be assigned to the default one.

I would like to assign everything to a specific cluster. Otherwise I could end up with the fact that some events are not replayed when doing a cluster replay because the didn’t belong to that cluster…

Regards,
Stein

I assume the DAO’s are proxied by Axon? You could try to set a breakpoint in AbstractClusterSelector on line 33. Start you application in debug mode and see if the DAO’s are properly recognized as EventListenerProxy instances.

Hi Allard,

I made a screenshot (see attachment) of how what it looks like… I’m not sure whether the dao’s are proxied by Axon.

Thnx!

Onegini logo small signature[18].png

PastedGraphic-1.png

Hmm, interesting. Do you use the axon:annotation-config element to enable annotations, or did you ‘manually’ wrap the event handlers?
And just to be sure, which Axon version is this?

Cheers,

Allard

Hi Allard,

I’m using the axon:annotation-config/ in combination with the @EventHandler annotations indeed.

It’s axon 2.0.3.

Onegini logo small signature[18].png

Hi Stein,

since your actual even handler is a proxy, it is not annotated with @Repository. Unfortunately, the AnnotationClusterSelector does not look at superclasses for annotations (as documented).

I just checked in some modifications on the 2.0.x branch (and master) that allow you to indicate whether you want to inspect super classes or not (not doing so is the default). I will release 2.0.4 soon.

Cheers,

Allard