jakarta-eewildflycdicustom-scope

CDI Extension class makes Wildfly container bean discovery fail


In preparation for adding a custom CDI scope, I have added a class that implements the CDI spi Extension interface. The class has no code in it:

public class TaskScopedExtension implements Extension, Serializable {
}

Simply including the class in the deployment causes all of the other CDI bean discovery to fail. I have not added any other code or files. Apparently Wildfly scans the deployment looking for the Extension, but I can't figure out why just including the class would cause the rest of the injections to fail. I haven't found anything helpful in the Java EE or Weld documentation. I have tried adding Observables on the before and after bean discovery events, and I have tried adding the javax.enterprise.inject.spi.Extension file to the deployment. Neither of those seems to make a difference.

Any help is appreciated.


Solution

  • I suppose you are running into one very peculiar part of the specification. Perhaps a leftover retained for backward compatibility. It is section 12.1 Bean Archives - "An archive which contains an extension and no beans.xml file is not a bean archive."

    Add beans.xml with desired discovery mode (or even empty one) and you should have it operational again.