Duplicated rosterID

Version 2

    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"):




    lastRosterID() { 
        int count = 0; 
        Connection con = 
        PreparedStatement pstmt = 
        ResultSet rs = 
        try { 
              con = DbConnectionManager.getConnection();
              pstmt = con.prepareStatement(
    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.