As pointed out in the official documentation, @BeforeClass
is not supported by Pax Exam, at least not in the expected way. It is executed by the JUnit driver and not inside the test container, that's why there is no bundle context.
If you want your code to be run in the container, it has to be in a bundle.
This question has been discussed here.