Duplicated rosterID

For those who, like me, added to jiveRoster table some users manually, they won’t be able to add users to the roster neither by Spark or by the admin console.

The solution passes by changing the source of Openfire (file: src/java/org/jivesoftware/openfire/roster/RosterItemProvider.java ).

Place (before “public RosterItem createItem”):

public int lastRosterID() {     int count = 0;     Connection con = null;     PreparedStatement pstmt = null;     ResultSet rs = null;     try {           con = DbConnectionManager.getConnection();
          pstmt = con.prepareStatement( "SELECT rosterID FROM jiveRoster ORDER BY rosterID DESC LIMIT 0,1");           rs = pstmt.executeQuery();           if(rs.next()) {               count = rs.getInt(1);
          }     }     catch (SQLException e) {
          Log.error(LocaleUtils.getLocalizedString("admin.error"), e);      }     finally {           DbConnectionManager.closeConnection(rs, pstmt, con);
    }     return count+1; }

And then, replace (or comment) what’s on “long rosterID” by:

long rosterID = lastRosterID();

Hope this was usefull.

Hey JR,

Going directly to the database is not recommended. We said that many times. The server will not pick up the changes and things will enter into a weird state. If you have to make changes directly to the database then you will need to restart the server and also make sure that your changes are complete and correct. For instance, if you are adding rows to a table then make sure to update the jive ID table to be in synch.

What we do recommend is using the Openfire API for making changes to the database and avoid having to restsart the server.

The best solution for my problem so far was to add directly in the database. It’s not perfect, you’re right. The user will only be able to see the changes in roster after logout/login.

I’m integrating Openfire/Spark with an already done PHP application (and I’m not a Java expert), but I’m considering to “lose” some time to create a plugin to manage what I need to do (add contacts to user’s roster).

I’ve just realized how dumb I had been!

I’m using cURL for somethings (for example to get the online list, to reload cache, get statistics)… Why shouldn’t I use it to add users to roster?

Most of my problems is now solved!