Defect formation in long Josephson junctions