Bruno Rozendo
Bruno Rozendo

Reputation: 335

RESTEASY003190: Could not find constructor for class

I'm trying setup a very basic tomcat 10+Resteasy 6.2.8.Final+CDI (weld 5.1.2.Final) (the latest as I'm writing)

The documentation: https://docs.jboss.org/resteasy/docs/6.2.8.Final/userguide/html_single/#standalone_resteasy

But when running:

java.lang.RuntimeException: RESTEASY003190: Could not find constructor for class: com.cdi.GreetingResource

my code: https://github.com/brunorozendo/jakarta-ee-10/tree/main/cdi

package com.cdi;


import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

@Path("/greet")
public class GreetingResource {

    private final GreetingService greetingService;

    @Inject
    public GreetingResource(GreetingService greetingService) {
        this.greetingService = greetingService;
    }

    @GET
    public String get() {
        greetingService.setName("bruno");
        greetingService.createMessage();
        return greetingService.getMessage();
    }
}
package com.cdi;

import jakarta.enterprise.context.RequestScoped;

@RequestScoped
public class GreetingService {

    private String name;
    private String message;

    public void createMessage() {
        message = "Hello, " + getName() + "!";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMessage() {
        return message;
    }

}

Upvotes: 1

Views: 375

Answers (0)

Related Questions