
779 So.2d 1216 (2000)
Ex parte CAPSTONE DEVELOPMENT CORPORATION and Capstone Properties Corporation.
(Re Ronald W. Johnson et al. v. Capstone Development Corporation et al.)
1982292.
Supreme Court of Alabama.
September 1, 2000.
Roger L. Bates and Edwin O. Rogers of Hand Arendall, L.L.C., Birmingham, for petitioners.
E. Glenn Waldrop, Jr., of Lightfoot, Franklin & White, L.L.C., Birmingham, for respondents.
*1217 PER CURIAM.
Capstone Development Corporation and Capstone Properties Corporation, defendants in a civil action pending in the Jefferson Circuit Court, petition for a writ of mandamus directing Judge Jack D. Carl, to enter an order (1) vacating the order of September 9, 1999, that denied their motion to dismiss; (2) granting their motion to dismiss; and (3) dismissing with prejudice the respondents' complaint. They contend they are entitled to a dismissal on the basis that the action is barred by the doctrine of res judicata. We deny the writ.
Capstone Development Corporation and Capstone Properties Corporation (hereinafter jointly referred to as "Capstone") are corporations organized and existing under Alabama law. Capstone is the general partner of two limited partnerships organized to develop and operate university-student apartments in Tuscaloosa, Alabama (University Commons-Tuscaloosa, Ltd.), and Athens, Georgia (Capstone Commons-Athens, Ltd.). Johnson Properties Limited ("JPL") is a limited partner in University CommonsTuscaloosa, Ltd. and Capstone CommonsAthens, Ltd. Ronald W. Johnson is the general partner of JPL.
On December 18, 1998, JPL filed its first action against Capstone, styled Johnson Properties Limited v. Capstone Development Corp. ("JPL I"), claiming, among other things, mismanagement and selfdealing by Capstone in its role as general partner of the partnerships. On January 22, 1999, Capstone moved to dismiss the complaint, asserting that, because the action was a derivative action involving a limited partnership, the plaintiff was required to comply with Rule 23.1, Ala. R.Civ.P. Capstone asserted that the plaintiff had failed to comply with Rule 23.1, by failing to make the necessary demand for action before filing the complaint. Capstone further asserted that the plaintiff did not meet the Rule 23.1 requirement that the plaintiff fairly and adequately represent the interests of the limited partners. On March 11, 1999, the trial court granted Capstone's motion to dismiss, noting on the case action summary: "The court finds that the claims set out in the complaint in this case are in the nature of derivative claims and that the rules pertaining to derivative actions must be followed. The motion to dismiss filed 1/22/99 is granted. Costs taxed as paid."
The plaintiff in JPL I did not move to alter, amend, or vacate the judgment of dismissal, nor did it appeal. However, on May 11, 1999, another lawsuit against Capstone was filed. The second lawsuit was styled Ronald W. Johnson et al. v. Capstone Development Corporation et al. ("JPL II"). On July 23, 1999, Capstone moved to dismiss JPL II on the bases that it was barred by the doctrine of res judicata, and that it suffered the same Rule 23.1 defects that had proved fatal to JPL I. On September 9, 1999, the trial court denied Capstone's motion to dismiss, stating: "The Motion to Dismiss filed 7/23/99 is DENIED. All proceedings in this case are stayed for a period of 14 days to allow Defendants to file a mandamus petition. If no mandamus is filed within 14 days the case shall proceed routinely." On September 23, 1999, Capstone filed this petition for the writ of mandamus.
The writ of mandamus is a drastic and extraordinary remedy, to be issued only when there is (1) a clear legal right in the petitioner to the order sought; (2) an imperative duty upon the respondent to perform, accompanied by a refusal to do so; (3) the lack of another adequate remedy; and (4) properly invoked jurisdiction of the court. Ex parte Horton, 711 So.2d 979, 983 (Ala.1998) (citing Ex parte United Serv. Stations, Inc., 628 So.2d 501 (Ala. 1993)); Ex parte Alfab, Inc., 586 So.2d 889, 891 (Ala.1991) (citing Martin v. Loeb & Co., 349 So.2d 9 (Ala.1977)). Moreover, "`[t]he right sought to be enforced by mandamus must be clear and certain with no reasonable basis for controversy about the right to relief,'" and "`[t]he writ will *1218 not issue where the right in question is doubtful.'" Ex parte Bozeman, 420 So.2d 89, 91 (Ala.1982) (quoting Ex parte Dorsey Trailers, Inc., 397 So.2d 98, 102 (Ala. 1981)).
The late Justice Bloodworth set out the elements of the doctrine of res judicata in Wheeler v. First Alabama Bank of Birmingham, 364 So.2d 1190, 1199 (Ala.1978):
"The elements of res judicata are as follows: (1) prior judgment rendered by court of competent jurisdiction; (2) prior judgment rendered on the merits; (3) parties to both suits substantially identical; and (4) same cause of action present in both suits. If these elements are present, then the former judgment is an absolute bar to any subsequent suit on the same cause of action, including any issue which was or could have been litigated in the prior action."
(Citations omitted.) See also Green v. Wedowee Hosp., 584 So.2d 1309, 1315 (Ala. 1991); Sanders v. First Bank of Grove Hill, 564 So.2d 869, 872 (Ala.1990); Leverette ex rel. Gilmore v. Leverette, 479 So.2d 1229, 1235 (Ala.1985) (all quoting Wheeler).
In JPL II, the first, third, and fourth elements are present: the judgment in JPL I was rendered by a court of competent jurisdiction; the parties to JPL I were substantially identical to those in JPL II; and the cause of action presented in JPL I is presented in JPL II. However, in order to determine whether Capstone has a clear legal right to the order sought, namely, an order dismissing the complaint in JPL II, we must determine whether the trial court's dismissal of JPL I was an adjudication on the merits of that case. If so, then all four elements of the doctrine of res judicata are met.
Rule 41(b), Ala.R.Civ.P., provides:
"For failure of the plaintiff to ... comply with these rules ..., a defendant may move for dismissal of an action or of any claim against the defendant. Unless the court in its order for dismissal otherwise specifies, a dismissal under this subdivision and any dismissal not provided for in this rule, other than a dismissal for lack of jurisdiction, for improper venue, or for failure to join a party under Rule 19, operates as an adjudication upon the merits."
The trial court's order dismissing JPL I did not specify whether the dismissal was with or without prejudice; therefore, Capstone argues, the dismissal of JPL I operated as an adjudication upon the merits of the plaintiffs' claims, for failure "to comply with these rules." We disagree. Rule 41(b) does not apply to a failure to comply with the rules that occurs before the commencement of the action, such as while the plaintiff is drafting the complaint. If it did, then an adjudication upon the merits could be achieved merely by obtaining a dismissal of a complaint for failure to comply with Rule 10(b), Ala. R.Civ.P., which requires that all averments of a claim be set forth in numbered paragraphs. Such a result is expressly condemned in the last paragraph of the Committee Comments to Rule 10.
Under this rationale, we treat the dismissal of JPL I as falling under the Rule 41(b) exception for a dismissal "for lack of jurisdiction." Thus, we conclude, the dismissal of JPL I is to be treated as a dismissal without prejudice. This decision accords with the concept of "lack of jurisdiction" found in the analogous federal rule, Rule 41(b), Fed.R.Civ.P., and it is supported by the decision in Costello v. United States, 365 U.S. 265, 81 S.Ct. 534, 5 L.Ed.2d 551 (1961). There, the Supreme Court held that Rule 41(b) was not intended to change the common-law principles of res judicata "with respect to dismissals in which the merits could not be reached for failure of the plaintiff to satisfy a precondition." 365 U.S. at 286, 81 S.Ct. 534. The Court stated:
"It is too narrow a reading of the exception to relate the concept of jurisdiction embodied [in the Rule] to the fundamental jurisdictional defects which render a *1219 judgment void and subject to collateral attack, such as lack of jurisdiction over the person or subject matter. We regard the exception as encompassing those dismissals which are based on a plaintiffs failure to comply with a precondition requisite to the Court's going forward to determine the merits of his substantive claim."
365 U.S. at 285, 81 S.Ct. 534 (emphasis added).
In Saylor v. Lindsley, 391 F.2d 965 (2d Cir.1968), the United States Court of Appeals for the Second Circuit, relying upon Costello, reversed the district court's holding that derivative claims were barred by the doctrine of res judicata where the derivative action was substantially the same as a prior complaint that had been filed on behalf of the same corporation. The earlier complaint had been dismissed for failure to comply with an order requiring a security-for-costs bond. The second action did not suffer from this defect. This view of the phrase "lack of jurisdiction" in Rule 41(b) has broad support. See 9 Charles Alan Wright & Arthur R. Miller, Federal Practice and Procedure, § 2373 at 405 (2d ed.1994) ("[C]ourts have recognized that Rule 41(b) does not apply in situations in which a case is dismissed because of some initial bar to reaching the merits of the plaintiff's claims...."). Directly on point is Kaplan v. Bennett, 465 F.Supp. 555 (S.D.N.Y.1979), where an earlier dismissal of a shareholders' derivative action for failure to make a demand on the board of directors was held not to have a preclusive effect. Bazata v. National Ins. Co. of Washington, 400 A.2d 313 (D.C.App.1979), relied upon by Capstone, is based upon an unpersuasive minority view.
Our caselaw supports the treatment we today give a dismissal based on a preaction failure to comply with a rule. In McMillon v. Hunter, 439 So.2d 153 (Ala. 1983), this Court declined to give a preclusive effect to a prior dismissal of a thirdparty claim for failure to comply with the "occurrence test" set forth in Rule 14, Ala.R.Civ.P. Chief Justice Torbert wrote:
"The trial court's ruling did not adjudicate the merits. Failure to properly join a party before filing a cross-claim or to comply with the occurrence test for a third-party complaint is a defect in jurisdiction, and any judgment as a result abates, but does not bar, the action. Professor Moore explains:
"`The tenor of Rule 56 indicates that the summary judgment procedure deals with merits; and that if granted in favor of a claimant it affirmatively adjudges the merits of the claim and if in favor of the defendant the judgment is in bar and not abatement.
"`. . . .
"`Matter in abatement ... only results in a dismissal of the action without prejudice; or, if the action is not then dismissed, temporarily stays the prosecution thereof or results in a transfer to another forum. The following illustrate matter in abatement: lack of jurisdiction over the subject matter; lack of jurisdiction over the person; improper venue; insufficiency of process; insufficiency of service of process; failure to join an indispensable party; incapacity of a party to sue; prematurity in bringing an action. A dismissal on any one or more of these defenses does not bar a subsequent action in a court of competent jurisdiction.'
"6 J. Moore, W. Taggart and J. Wicker, Moore's Federal Practice ¶ 56.03 (2d ed.1976)."
McMillon, 439 So.2d at 154 (emphasis added).
Because the trial court's dismissal of JPL I falls within the Rule 41(b) lack-of-jurisdiction exception, the decisions in Wal Mart Stores, Inc. v. Caples, 646 So.2d 1328 (Ala.1994), and Smith v. Union Bank & Trust Co., 653 So.2d 933 (Ala.1995), are, on their facts, distinguishable from this case and do not warrant issuance of the writ.
*1220 The complaint in JPL II complies with Rule 23.1, Ala.R.Civ.P. Therefore, Capstone's petition for the writ of mandamus is denied.
WRIT DENIED.
HOOPER, C.J., and MADDOX, HOUSTON, COOK, SEE, LYONS, BROWN, JOHNSTONE, and ENGLAND, JJ., concur.
