"Can not access user repository" error

Keren Meir
Added over 5 years ago


I upgrade my tigase version to 5.2.0 beta 3, and added a few changes.

Before the upgrade, it works good. Now, after the upgrade I have one problem.

My changes are:

In "handleLogin" function in SessionManager class I added the last line:

public void handleLogin(BareJID userId, XMPPResourceConnection conn) {
        if (log.isLoggable(Level.FINEST)) {
            log.log(Level.FINEST, "handleLogin called for: {0}, conn_id: {1}", new Object[] {
                    conn });
        registerNewSession(userId, conn);

The function "setContactHash" located in XMPPResourceConnection:

public void setContactHash() {
        try {
            this.contactHash = this.getData(null, CONTACTHASH_KEY, "FF");
        } catch (NotAuthorizedException e) {
            // TODO Auto-generated catch block
        } catch (TigaseDBException e) {
            // TODO Auto-generated catch block

the "getData" function has an exception:

tigase.xmpp.NotAuthorizedException: Can not access user repository.
    at tigase.xmpp.RepositoryAccess.getData(
    at tigase.xmpp.XMPPResourceConnection.setContactHash(
    at tigase.server.xmppsession.SessionManager.handleLogin(
    at tigase.cluster.SessionManagerClustered.handleLogin(
    at tigase.xmpp.XMPPResourceConnection.authorizeJID(
    at tigase.xmpp.impl.SaslAuth.process(
    at tigase.server.xmppsession.SessionManager$ProcessorWorkerThread.process(

What can be the problem?

(I'm using java 1.7, tigase 5.2.0 beta 3, all other calls to "getData" works good!)


Replies (3)


Added by Artur Hefczyc TigaseTeam over 5 years ago

This is because an internal state within XMPPResourceConnection is set to authorized only after the handleLogin method completes without any errors. Before the state is set to authorized you cannot call database for that connection. The behavior of previous version was incorrect, I think.

If you really want/need to modify Tigase's own code I suggest to do it in the handleResoueceBind instead. But the correct way to add a custom functionality would be to write own plugin which is called on, resource bind for example and then do your stuff in there. This way you do not have to modify Tigase code and have much less hassle on code update to a new version.

Added by Keren Meir over 5 years ago


According to the plugin- I added some plugins (to tigase.xmpp.impl) but the trigger of these plugins is a packet that sent/received with specific tag.

How can I add plugin to the login process? what is the trigger of this plugin and where exactly I put it?

Thanks again


Added by Artur Hefczyc TigaseTeam over 5 years ago

You are correct. Plugins are triggered by a XMPP stanza, not an event. This is why I suggested to make it a plugin triggered by resource bind stanza. You know that the user is already properly authenticated but he cannot yet communicate with other users. So this would be pretty much the same as handleLogin.

Alternatively, if you really want it to be a part of the login process you could write a plugin which extends the user authentication plugin and once authentication is completed you can do your stuff.