CDI beans in Xwiki Backend without beans.xml. it works but how?

Hello Everyone,
Im using Xwiki version 13 and Tomcat version 9.
i wrote some java classes. I register them to Component Manager by adding their name into components.txt
I have used some CDI bean Annotations in my classes such as @Inject ( i inject one of my classes into another of my Classes) and @RequesScoped for one Method.
the only xml files that i have are persistence.xml (because i use javax.persistence packages) and pom.xml
I dont have any beans.xml but it works very good. Fo example Inject annotation works fine.
How is it possible that whithout any beans.xml file i can use CDI beans in Xwiki? I assume that my classes are CDI beand because these Annotations that i wrote work very good.
The packages that i used for these annotations are :slight_smile:

This project is my Bachelor Project and i have to explaine why and how.
Can somebody please tell me how it is possible?

Thank you very much for your help.


what you’re looking for is all explained in Component Module ( TL;DR XWiki currently uses its own implementation for component injection and not CDI.

so i have question: does xwiki uses its own implementation of injection but when we want use it we import the javax.inject.Inject package?

and how can we explane the @RequestScoped when it is not CDI ?

thank you for your time :slight_smile:

All the answers are in Component Module (

XWiki doesn’t have a scope to register a component only for a HTTP request. Components are registered for a user, a space, a wiki or a farm.

@surli @vmassol Thank you both for the help. i understand how @Inject works.

and about @RequestScoped : i didnt use it for the whole class. i just used it for one Method in the Class and it works. what is your opninion about it?
Does it mean that CDI Scopes work in Classes that isnt CDI bean?

Can you please tell me where can i find this implementation? i want to mention it.
I searched but didnt find it yet.

it would be very kind if you show me that. thank you a lot

Click the “sources” button on Component Module (