sendRaw(reject, 0);
    public void generateReject(Message message, int err, int field) throws IOException,            FieldNotFound {        String reason = SessionRejectReasonText.getMessage(err);        if (!state.isLogonReceived()) {            throw new SessionException("Tried to send a reject while not logged on: " + reason                    + " (field " + field + ")");        }        String beginString = sessionID.getBeginString();        Message reject = messageFactory.create(beginString, MsgType.REJECT);        int msgSeqNum;        String msgType;        reject.reverseRoute(message.getHeader());        initializeHeader(reject.getHeader());        msgSeqNum = 0;        msgType = null;        boolean possDupFlag = false;        msgType = message.getHeader().getString(MsgType.FIELD);        if (message.getHeader().isSetField(MsgSeqNum.FIELD)) {            msgSeqNum = message.getHeader().getInt(MsgSeqNum.FIELD);        }        if (message.getHeader().isSetField(PossDupFlag.FIELD)) {            possDupFlag = message.getHeader().getBoolean(PossDupFlag.FIELD);        }        reject.setInt(RefSeqNum.FIELD, msgSeqNum);        if (beginString.compareTo(FixVersions.BEGINSTRING_FIX42) >= 0) {            reject.setString(RefMsgType.FIELD, msgType);            if ((beginString.equals(FixVersions.BEGINSTRING_FIX42) && err <= SessionRejectReason.INVALID_MSGTYPE)                    || beginString.compareTo(FixVersions.BEGINSTRING_FIX42) > 0) {                reject.setInt(SessionRejectReason.FIELD, err);            }        }        if (!msgType.equals(MsgType.LOGON) && !msgType.equals(MsgType.SEQUENCE_RESET)                && (msgSeqNum == getExpectedTargetNum() || !possDupFlag)) {            state.incrNextTargetMsgSeqNum();        }        if (reason != null && (field != 0 || err == SessionRejectReason.INVALID_TAG_NUMBER)) {            populateRejectReason(reject, field, reason);            state.logEvent("Message " + msgSeqNum + " Rejected: " + reason + ":" + field);        } else if (reason != null) {            populateRejectReason(reject, reason);            state.logEvent("Message " + msgSeqNum + " Rejected: " + reason);        } else            state.logEvent("Message " + msgSeqNum + " Rejected");        sendRaw(reject, 0);    }