Git Product home page Git Product logo

fork-axon-spring-boot-devtools-isssue's Introduction

Axon and Spring Boot Devtools

Axon 3.1.2 does not work with spring-boot-devtools:1.5.9.RELEASE.

Running the example

Failure scenario ๐Ÿ’ฉ

With the spring-boot-devtools dependency added, run the app with:

$ ./mvnw spring-boot:run

Then execute the following requests:

$ curl -X POST \
    http://localhost:8080/things \
    -H 'Content-Type: application/json' \
    -d '{
          "id": "1",
          "name": "Test"
  }'
1
  
$ curl -X PUT \
    http://localhost:8080/things/1 \
    -H 'Content-Type: application/json' \
    -d '{
  	"name": "Test 2"
  }'
{"timestamp":1515786529395,"status":500,"error":"Internal Server Error","exception":"org.axonframework.eventsourcing.IncompatibleAggregateException","message":"Aggregate identifier must be non-null after applying an event. Make sure the aggregate identifier is initialized at the latest when handling the creation event.","path":"/things/1"}  

and you'll see the error:

org.axonframework.eventsourcing.IncompatibleAggregateException","message":"Aggregate identifier must be non-null after applying an event. ...

Successful scenario โœ…

Now to "fix" the problem, comment out the spring-boot-devtools dependency:

...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- see https://github.com/AxonFramework/AxonFramework/issues/282 -->
        <!-- comment the spring-boot-devtools dependency out for the app to work on the PUT -->
        <!--<dependency>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-devtools</artifactId>-->
            <!--<optional>true</optional>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.axonframework</groupId>
            <artifactId>axon-spring-boot-starter</artifactId>
            <version>${axon.version}</version>
        </dependency>
...        

and run the app and requests as before:

$ ./mvnw clean spring-boot:run
...

$ curl -X POST \
    http://localhost:8080/things \
    -H 'Content-Type: application/json' \
    -d '{
          "id": "1",
          "name": "Test"
  }'
1
  
$ curl -X PUT \
    http://localhost:8080/things/1 \
    -H 'Content-Type: application/json' \
    -d '{
  	"name": "Test 2"
  }'
  
$  

no error and note that in the logs you'll see the event handler pick up the event:

2018-01-12 21:51:59.027  INFO 61931 --- [nio-8080-exec-2] com.example.ThingHandler                 : Thing changed: Test 2

Note

Running this application from the packaged Jar (with ./mvnw package && java -jar target/axon-spring-boot-devtools-isssue-1.0-SNAPSHOT.jar) works, even despite having spring-boot-devtools on the classpath.

Therefore the error occurs only when running in "development mode".

fork-axon-spring-boot-devtools-isssue's People

Contributors

donovanmuller avatar

Watchers

James Cloos avatar Maksim Kostromin avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.