Component injection failed


I’m currently trying to user other components in a custom component i’ve made. I follow the example but the component i try to import is always null.

I put above the code :

public class GetPagesService {

    private QueryManager queryManager;

    public String getVisiblesPages() {
          Class test = queryManager.getClass();

In this example queryManager is always null and i dont know what i miss. To add some precisions, i deploy my component manually.



Could you show us your components.txt? (see


BTW you’re also missing the lifecycle annotation. If you use xwiki’s maven build you should get errors about all these automatically.

Also you’re missing a role interface…

In short you need to follow :slight_smile:

This means GetPagesService is not a component. The @Component annotation is not enough to make all instances of this class components, it needs to be initialized as a component either by being injected in another component or by using ComponentManager#getInstance API (i.e. you cannot use new to create a component).