javaspring-bootaxon

Getting ForbiddenClassException in Axon/SpringBoot


I am trying to implement axon framework with spring boot.

Here is the version of jars.

  1. Spring Boot 2.6.1
  2. Java 17
  3. Axon 4.5.6

My Project Structure is:

I am getting the below exception while try to access the UserRegisteredEvent* from query application.

com.thoughtworks.xstream.security.ForbiddenClassException: com.tesla.user.core.events.UserRegisteredEvent
    at com.thoughtworks.xstream.security.NoTypePermission.allows(NoTypePermission.java:26) ~[xstream-1.4.18.jar:1.4.18]

Where I am going wrong?

Note:

I have tried downgrading my java version to 16 and spring boot to 2.4.* also .


Solution

  • I found the solution by adding XStream bean.

    @Bean
    public XStream xStream() {
        XStream xStream = new XStream();
    
        xStream.allowTypesByWildcard(new String[] { "com.example.**" });
        return xStream;
    }
    

    Detail in this post.

    Hope this help