Access Repository outside a request

Following the documentation I should be able to access the repository by the following line:

HippoRepository repository = HippoRepositoryFactory.getHippoRepository("vm://");

But that ends up in a java.lang.ClassNotFoundException: org.hippoecm.repository.LocalHippoRepository

What is my mistake?

HippoRepository repository = HippoRepositoryFactory.getHippoRepository("rmi://localhost:1099/hipporepository");
worked !

I guess the repository is running in cms-Application (JVM) , but my code is running in site-application - in a different JVM- correct?

So I had to enable rmi to get this work.
Are there any aspects against this approach - or is there even annother approach??

Further Investigation
No I tried to follow the code here

Repository repo = HstServices.getComponentManager().getComponent(Repository.class.getName());
Credentials creds = HstServices.getComponentManager().getComponent(Credentials.class.getName() + ".default");
ContentBeansTool cbt = HstServices.getComponentManager().getComponent(ContentBeansTool.class.getName());

Session session = null;

try {
    session = repo.login(creds);
    HstQueryManager queryManager = cbt.createQueryManager(session);

    final Node scope = JcrUtils.getNodeIfExists("/content/documents/myproject", session);
    final HstQuery hstQuery = HstQueryBuilder.create(scope)
    // ...
} finally {
    if (session != null) session.logout();

Unfortunately this code ends up in a NullPointerException when trying to connect to the repo :frowning:
I am getting frustrated :frowning_man:

Is there really nobody, who can help ???

Hey, if you are trying to get the JCR session in site application then you can easily get it by following way

HstRequestContext requestContext = RequestContextProvider.get();
Session session = requestContext.getSession()

And this works without a request ? As I remember I tried that before - and when I am not wrong RequestContextProvider was null !?

The use case is to query the repository from a ValueListProvider to dynamically populate a dropdown in a ComponentInfo-Interface !!!

Then the code should be in the cms module instead of the site ?

?? The documentation (see the provided link) says:

In cases where you don’t have a HstRequestContext (for example for during some background process or for external application integration that does not involve an HTTP request), you can get hold of the HstQueryManager to build an HstQuery with it (through HstQueryBuilder#build(HstQueryManager) method:

I would prefer to keep all custom code in site-modul (like the ComponentInfo-Interfaces)!

If you are talking about this ValueListProvider then it must be in the cms module because it will be called by the CMS configuration.

No, I am talking about @DropDownList - Annotation for Component Configuration Parameters, as described here:

The set of values can also be dynamically pulled from an implementation of org.hippoecm.hst.core.parameters.ValueListProvider:

@Parameter(name = "cssDisplay2", displayName = "CSS Display 2")
@DropDownList(valueListProvider = CssDisplayValueListProvider.class)
String getCssDisplay2();

Class org.hippoecm.repository.LocalHippoRepository is under this library hippo-repository-engine.jar
You need to check why your module does not have this library in the class path. Using RMI is an option but not a very good way in this case.

For which solution? Getting the repository with:
Repository repo = HstServices.getComponentManager().getComponent(Repository.class.getName());

Can you supply a full example?