1

Lets say I have a class hierarchy of Human and Student classes like this:

public abstract class Human{

    private final String type;

    public Human(String type) {
        this.type = type;
    }
}

@Stateless
public class Student extends Human {

    public Student() {
        super("STUDENT");
    }
}

I only need a managed bean of class Student. But on class Human, I get an error saying:

Managed Bean must have a constructor with no parameters, or a constructor annotated @Inject

Is there a way to tell Java that I don't want a managed bean of type Human, and therefore I don't need a parameterless constructor?

Jardo
  • 1,939
  • 2
  • 25
  • 45
  • I suspect that the fact that `Student` extends `Human` means that `Human` has to support the managed bean expectations. Have you tried adding the Inject annotation to the parameterized constructor of `Human`? – vsfDawg Aug 18 '21 at 16:42

0 Answers0