Search code examples
jakarta-eecdicompletable-future

NoSuchMethodError - CDI fireAsync


I am trying to use the new fireAsync Method which comes with CDI 2. I am running on a Wildfly 10.1.0. I always get an error by calling the fireAsnyc() Method:

javax.servlet.ServletException
    Caused by: java.lang.NoSuchMethodError: javax.enterprise.event.Event.fireAsync(Ljava/lang/Object;)Ljava/util/concurrent/CompletionStage;

This is my code:

@Inject Event<Customer > customerEvent ;

public String save() {
    Customer customer = new Customer("Max", "Smith");
    customerEvent.fireAsync(customer);
    return "something";
}

And my pom.xml:

    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>

Solution

  • Wildfly 10.1 is using Java EE 7 which ships CDI 1.2/Weld 2.3. You can upgrade it to CDI 2, there's a patch available if you look at the weld blog