
891 So.2d 341 (2004)
Daniel WAITE, Sr.
v.
Margaret Susan Helmondollar WAITE and Reese Helmondollar.
2030017.
Court of Civil Appeals of Alabama.
April 9, 2004.
Albert L. Jordan and Matthew D. Fridy of Wallace, Jordan, Ratliff & Brandt, L.L.C., Birmingham, for appellant.
Sheldon Perhacs, Birmingham, for appellee Margaret Susan Helmondollar Waite.
THOMPSON, Judge.
On August 21, 2003, Daniel Waite, Sr., filed a declaratory-judgment action against Margaret Susan Helmondollar Waite ("Margaret") and Reese Helmondollar (hereinafter together referred to as "the defendants"). Seven days later, on August 28, 2003, the trial court, on its own motion, entered a judgment in favor of the defendants. Waite appealed.
The record indicates that in 1960 Margaret and Helmondollar obtained a divorce by a judgment ("the 1960 divorce judgment") of the trial court. Waite and Margaret married in 1968. Four children were born of their marriage. Waite and Margaret now reside in Texas. It appears that Waite and Margaret separated sometime in 1999, and Margaret initiated divorce proceedings in Texas.
On December 28, 2001, Waite filed a complaint in the trial court in which he alleged that at the time Margaret and Helmondollar sought their divorce, neither party to the 1960 divorce judgment had satisfied the residency requirements for obtaining a divorce in Alabama. Waite sought a judgment declaring the 1960 divorce judgment void. In his 2001 declaratory-judgment action, Waite named only Margaret as a defendant. It appears from *342 the record on appeal that in prosecuting the 2001 declaratory-judgment action, Waite wanted to have the 1960 divorce judgment declared void to aid in his attempt to have his 33-year marriage to Margaret invalidated.
Margaret moved to dismiss the 2001 declaratory-judgment action. In her motion to dismiss, Margaret alleged, among other things, that Waite lacked standing to bring that action and that Waite had failed to join certain indispensable parties. On February 8, 2002, the trial court entered a notation on Margaret's motion to dismiss indicating that it granted that motion. Waite filed a postjudgment motion. The trial court conducted a hearing on Waite's postjudgment motion, and it received ore tenus evidence. On May 16, 2002, the trial court entered an order denying Waite's motion to alter, amend, or vacate its February 8, 2002, judgment.
Waite appealed the trial court's judgment in the 2001 declaratory-judgment action to our supreme court.[1] On March 28, 2003, our supreme court affirmed the trial court's judgment in the 2001 declaratory-judgment action without issuing an opinion; the court cited Yerger v. Cox, 281 Ala. 1, 198 So.2d 282 (1967),[2] in its no-opinion affirmance. Waite v. Helmondollar (No. 1011686, March 28, 2003), 881 So.2d 546 (Ala.2003) (table).
On August 21, 2003, after the supreme court issued its decision in Waite v. Helmondollar, supra, Waite filed a second declaratory-judgment action in the trial court. The 2003 declaratory-judgment action was assigned to the same trial judge that had considered the 2001 declaratory-judgment action. In the 2003 declaratory-judgment action, Waite named Margaret and Helmondollar as defendants; in that action, he sought to have the 1960 divorce judgment declared void because, he alleged, the evidence presented during Margaret and Waite's divorce proceedings in Texas established that the parties to the 1960 divorce judgment did not allege or prove the residency requirements necessary to invoke the jurisdiction of the court that entered the 1960 divorce judgment.
On August 28, 2003, seven days after Waite filed the 2003 declaratory-judgment action, the trial court, on its own motion, entered a judgment in favor of the defendants. The trial court cited the doctrine of res judicata in entering that part of its judgment in favor of Margaret and the doctrine of collateral estoppel in that part of its judgment in favor of Helmondollar.
Waite raises several arguments in his brief on appeal. However, we find that his argument that the trial court could not, on *343 its own motion, dismiss this action to be dispositive.
Several federal courts have affirmed a trial court's dismissal, on its own motion, of an action based on the doctrine of res judicata; those courts cited, among other reasons, the consideration of judicial economy in reaching those judgments. Arizona v. California, 530 U.S. 392, 120 S.Ct. 2304, 147 L.Ed.2d 374 (2000); In re Colonial Mortgage Bankers Corp., 324 F.3d 12, 16 (1st Cir.2003); Mowbray v. Cameron County, Texas, 274 F.3d 269 (5th Cir.2001); In re Medomak Canning, 922 F.2d 895 (1st Cir.1990); and Headwaters v. United States Forest Serv., 159 F.Supp.2d 1253, 1255 (D.Or.2001).
Other courts, however, have concluded that a trial court may dismiss an action on its own motion, but only if the basis for that dismissal is jurisdictional. See People v. Matulis, 117 Ill.App.3d 876, 454 N.E.2d 62, 73 Ill.Dec. 318 (1983) (the trial court erred in dismissing, sua sponte, the action because the defect was not jurisdictional). See also Diamond Nat'l Corp. v. Dwelle, 164 Conn. 540, 325 A.2d 269 (1973); Lease Partners Corp. v. R & J Pharmacies, Inc., 329 Ill.App.3d 69, 768 N.E.2d 54, 263 Ill.Dec. 294 (2002); Adams v. Inman, 892 S.W.2d 651 (Mo.Ct.App.1994); and Neal v. Maniglia, (No. 75566, April 6, 2000) (Ohio Ct.App.2000) (not published in Ohio Appellate Reports or in North Eastern Reporter). In two of those cases, the courts determined that the statute of limitations served as a jurisdictional basis that supported affirming a trial court's sua sponte dismissal of an action. Diamond Nat'l Corp. v. Dwelle, supra; Neal v. Maniglia, supra. However, in several of the other cases, the courts concluded that, although a trial court is permitted to dismiss an action based on a lack of jurisdiction, the statute of limitations is not a proper basis for such a dismissal because the statute of limitations is an affirmative defense that must be raised by a party. Lease Partners Corp. v. R & J Pharmacies, Inc., supra; Adams v. Inman, supra. See also McCarvill v. McCarvill, 144 Or.App. 437, 441, 927 P.2d 115, 116 (1996) (a trial court "may not raise defenses on its own and then dismiss the complaint on the basis of its determination of the defenses"); Francke v. Gable, 121 Or.App. 17, 853 P.2d 1366 (1993) (a trial court may not raise an affirmative defense on behalf of a defendant and then dismiss the action based on that defense).
The doctrines of res judicata and collateral estoppel are affirmative defenses, Rule 8(c), Ala. R. Civ. P.; Lee L. Saad Constr. Co. v. DPF Architects, P.C., 851 So.2d 507, 516 (Ala.2002), and do not affect a court's jurisdiction to consider an action. Affirmative defenses may be waived if they are not pleaded by a party against whom a claim is asserted. Rule 8(c), Ala. R. Civ. P.; Bechtel v. Crown Cent. Petroleum Corp., 451 So.2d 793 (Ala.1984) (citing 2A J. Moore, Federal Practice § 8.27[3] at 8-251 (2d ed.1948)). By its actions in the present case, the trial court, in essence, asserted the affirmative defenses of the doctrines of res judicata and collateral estoppel on behalf of the defendants and dismissed the matter based on those affirmative defenses.
After careful consideration, we find most persuasive the reasoning of the courts that have held that, although a trial court may dismiss an action on its own motion on a jurisdictional basis, affirmative defenses such as the statute of limitations or the doctrines of res judicata are not jurisdictional bases upon which a court may base a sua sponte dismissal. See Lease Partners Corp. v. R & J Pharmacies, Inc., supra; Adams v. Inman, supra. Therefore, we must conclude that the trial court erred in dismissing the action, on its own motion, *344 based upon affirmative defenses not asserted by the defendants.
REVERSED.
YATES, P.J., and CRAWLEY, PITTMAN, and MURDOCK, JJ., concur.
NOTES
[1]  Apparently, neither party to the 2001 declaratory-judgment action contested the jurisdiction of the Alabama Supreme Court to hear that appeal, and neither party addresses that issue in this appeal. In any event, this court could not set aside a judgment of our supreme court. Waite appealed the judgment in the 2003 declaratory-judgment action that forms the basis of this appeal to the supreme court, and that court transferred the appeal to this court on the basis that this court has appellate jurisdiction. But see Ex parte Galanos, 796 So.2d 390 (Ala.2000); Evers v. Link Enters., Inc., 386 So.2d 1177 (Ala.Civ.App.1980).
[2]  In Yerger v. Cox, supra, the children of a decedent sought to have a divorce judgment obtained by the decedent's second wife, the children's stepmother, before her marriage to the decedent declared void. If the stepmother's divorce had been held void, thus invalidating the stepmother's marriage to the decedent, the children would have received a greater amount in military survivor benefit payments. All of the parties to the action were nonresidents of Alabama. Our supreme court held that the decedent's children, who were "strangers" to their stepmother's divorce judgment, could not seek to have that judgment declared void.
