eventuate-clients / eventuate-client-java

Eventuate Java client
Other
53 stars 31 forks source link

ReflectiveMutableCommandProcessingAggregate no method found exceptions on find or loading aggregate with events #10

Open jltnf54 opened 6 years ago

jltnf54 commented 6 years ago

The following method fails to call apply on an subclass aggregate.

   @Override
  public T applyEvent(Event event) {
    try {
      getClass().getMethod("apply", event.getClass()).invoke(this, event);
    } catch (InvocationTargetException e) {
      throw new EventuateApplyEventFailedUnexpectedlyException(e.getCause());
    } catch (NoSuchMethodException e) {
      throw new MissingApplyMethodException(e, event);
    } catch (IllegalAccessException e) {
      throw new EventuateApplyEventFailedUnexpectedlyException(e);
    }
    return (T)this;
  }

NoSuchMethodException is thrown when you have:

public void apply(Myevent event) {}

when loading an aggregate or saving and aggregate with previous events.

cer commented 6 years ago

Please explain what you mean by "subclass aggregate"? What are your hierarchies of aggregate and event classes?

jltnf54 commented 6 years ago

Example:

class MyAgregate extends RefelectiveMutableCommandProcessingAggrgate

And

Interface MyEvent extends Event

jltnf54 commented 6 years ago

It work fine on the initial aggregaterepository.save()

But loading

aggregaterepository.find(identifier)

It fails to retrieve the apply method on the aggregate and cannot be passed to apply(MyEvent) since the signatures do not match, when retrieving the events from eventuate local dB events table

cer commented 6 years ago

That's very strange. Are you using some tool/framework that manipulates class loaders, e.g. live reloading framework?

On Wed, Jun 27, 2018 at 11:59 AM, jltnf54 notifications@github.com wrote:

It work fine on the initial aggregaterepository.save()

But loading

aggregaterepository.find(identifier)

It fails to retrieve the apply method on the aggregate and cannot be passed to apply(MyEvent) since the signatures do not match, when retrieving the events from eventuate local dB events table

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/eventuate-clients/eventuate-client-java/issues/10#issuecomment-400792884, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPB2hvwxwjK5wpp4m3JV_aoxYDBsh0Jks5uA9YdgaJpZM4U6Mq9 .

-- Learn microservices - http://learn.microservices.io Microservices application platform http://eventuate.io Consulting and training http://chrisrichardson.net

jltnf54 commented 6 years ago

no

jltnf54 commented 6 years ago

i can send my maven dependencies.

jltnf54 commented 6 years ago

I think i found the issue. It is spring boot dev tools

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <optional>true</optional>
    </dependency>

once i removed this it works now

cer commented 6 years ago

I believe that Spring Boot DevTools does something with class loaders that results in a MethodNotFoundException.

On Wed, Jun 27, 2018 at 12:45 PM, jltnf54 notifications@github.com wrote:

I think i found the issue. It is spring boot dev tools

org.springframework.boot spring-boot-devtools true

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/eventuate-clients/eventuate-client-java/issues/10#issuecomment-400806283, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPB2gFxGnq1bKv70nsgaq0uRuKc4DOxks5uA-D1gaJpZM4U6Mq9 .

-- Learn microservices - http://learn.microservices.io Microservices application platform http://eventuate.io Consulting and training http://chrisrichardson.net