
201 S.W.3d 576 (2006)
Brenda Ann SHELTON, Respondent,
v.
Edward Palmer SHELTON, Appellant.
No. WD 66148.
Missouri Court of Appeals, Western District.
September 26, 2006.
*578 M. Andrew Roffmann, Liberty, MO, for appellant.
R. Gregory Harrison, Liberty, MO, for respondent.
Before JAMES M. SMART, JR., P.J., EDWIN H. SMITH, and LISA WHITE HARDWICK, JJ.
*577 JAMES M. SMART, JR., Judge.
Edward Shelton appeals the trial court's denial of his petition for declaratory judgment. He says the effect of the denial was to erroneously award his former spouse, Brenda Shelton, a portion of his disability annuity, when the dissolution decree only awarded her a portion of his retirement benefits. We dismiss the appeal for lack of jurisdiction.

Statement of Facts
The fourteen-year marriage of Edward Shelton and Brenda Shelton was dissolved by default judgment in December 1986. Mr. Shelton ("Edward") was not represented by counsel and did not appear at the final hearing. Pursuant to the dissolution decree, Ms. Shelton ("Brenda") was awarded a marital share of Edward's retirement/pension plan from his employer, Union Pacific Railroad Company.
Edward, who has not yet reached retirement age, has become disabled since the dissolution. At some point after the dissolution, Brenda submitted a copy of the dissolution decree to the Railroad Retirement Board, the body that administers the Railroad Retirement Plan. After Edward became disabled, the Board began making deductions from Edward's disability payments and paying Brenda.
Edward contacted the Board about the deductions. The Board responded that it would not discontinue the division of the payments without a new court order.
In February 2005, Edward filed a petition for declaratory judgment and motion for contempt naming Brenda as party defendant. Edward sought a declaration from the court that Brenda is not eligible to receive any portion of his disability annuity *579 from his employer and that she is only eligible to receive a portion of his retirement benefits "as contemplated by the original Decree." Brenda's answer contended the petition should be dismissed.
On October 31, 2005, the court denied Edward's petition for declaratory judgment and denied his motion for contempt. The court's judgment stated that it ruled for Brenda and against Edward on Edward's petition for declaratory judgment. Because Brenda's pleadings sought only dismissal of the petition, the court's ruling was not a ruling on the merits.
Edward appeals.

Edward's Primary Argument
In his first point, Edward contests the trial court's denial of his petition for declaratory judgment, which he fears had the effect of awarding Brenda a portion of his disability benefit. This was error, he says, because under Missouri law, a disability annuity is not marital property subject to division in a dissolution decree. See Cranor v. Cranor, 118 S.W.3d 222 (Mo.App. 2003), and In re Marriage of Cranor, 78 S.W.3d 150 (Mo.App.2002). Edward says the dissolution decree awarded Brenda only a marital share of his retirement/pension plan when he receives it, and, he points out, he is not currently receiving any portion of his retirement benefits because he has not reached retirement age. Edward argues that the disability benefits he is receiving are intended to compensate him for loss of future earnings due to his physical disability and are not deferred compensation for past services, as is true with retirement benefits. Because we conclude that the appeal must be dismissed, we do not reach the merits of this argument.

Dismissal for Lack of Jurisdiction
It is well settled that before we can proceed with the review of an appeal on the merits, we first must determine, sua sponte, our jurisdiction to do so. Derks v. Surface, 189 S.W.3d 692, 694 (Mo. App.2006). If we lack jurisdiction, then the appeal must be dismissed. Id. This court's appellate jurisdiction is derivative. In re Moreau, 161 S.W.3d 402, 405 (Mo. App.2005). If the trial court lacked jurisdiction to enter the judgment on which review is sought, then we lack jurisdiction to review it on the merits. Id. Thus, we are required to determine, sua sponte, whether the trial court had jurisdiction to adjudicate the matter at hand. Id.
For the reasons stated below, we conclude that the trial court lacked jurisdiction to consider Edward's declaratory judgment action, and we, therefore, are constrained to dismiss this appeal for lack of jurisdiction.

Failure to State a Claim for Declaratory Judgment
Although not raised by the parties, the issue of whether a petition states a claim upon which relief can be granted is "inherent in every appeal and may be raised sua sponte by the reviewing court." Preferred Physicians Mut. Mgmt. Group, Inc. v. Preferred Physicians Mut. Risk Retention Group, 916 S.W.2d 821, 823 (Mo. App.1995).
Under the Declaratory Judgment Act, trial courts have the power "to declare rights, status, and other legal relations." § 527.010.[1] There are four requirements *580 for a declaratory judgment petition. Grewell v. State Farm Mut. Auto. Ins. Co., 102 S.W.3d 33, 36 (Mo. banc 2003). In addition to demonstrating that a justiciable controversy exists, it is required that there is a legally protected interest directly at issue, that the question presented is ripe for judicial determination, and that the petitioner does not have an adequate remedy at law. Id. When a court's declaratory judgment power is improperly invoked because an adequate remedy already exists, that claim fails to state a cause of action. Preferred Physicians, 916 S.W.2d at 825. Such a claim "is a nullity and not subject to being ruled on" by the court. Van Dyke v. LVS Bldg. Corp., 174 S.W.3d 689, 694 (Mo.App.2005).
Here, Edward could have  and should have  petitioned the court to invoke its continuing jurisdiction to establish a qualified domestic relations order (QDRO). In such a proceeding, the parties could litigate the merits of Edward's contentions. We conclude, therefore, that Edward's petition for declaratory judgment failed to state a claim upon which relief can be granted. The failure to state a claim is related to subject matter jurisdiction. Id. at 694. Subject matter jurisdiction cannot be waived or conferred by agreement of the parties. Id. (citing Noakes v. Noakes, 168 S.W.3d 589, 596 (Mo.App.2005)). Because Edward failed to state a claim for declaratory judgment, the trial court was without jurisdiction to consider his petition.

Other Adequate Remedy: QDRO
Edward argues in his second point that the trial court denial was "tantamount to a modification" of the order dividing the parties' property under the dissolution decree. Such an order is not modifiable, he says. See § 452.330.5. It is true that once a decree or judgment for dissolution of marriage becomes final, the property provisions of the decree generally are not modifiable under Missouri law. Ochoa v. Ochoa, 71 S.W.3d 593, 595 (Mo. banc 2002); § 452.330.5. Section 452.330.5, however, provides for the following limited exception:
The court's order as it affects distribution of marital property shall be a final order not subject to modification; provided, however, that orders intended to be qualified domestic relations orders [QDROs] affecting pension, profit sharing and stock bonus plans pursuant to the U.S. Internal Revenue Code shall be modifiable only for the purpose of establishing or maintaining the order as a qualified domestic relations order or to revise or conform its terms so as to effectuate the expressed intent of the order.
This statute has been interpreted to mean that the court retains continuing jurisdiction to establish, to maintain, or to revise a QDRO to ensure that it is "qualified." May v. May, 801 S.W.2d 728, 736 (Mo. App.1990). Pursuant to the statute, a domestic relations order that is intended to be a QDRO may be modified in order to "establish" it as a QDRO. Ochoa, 71 S.W.3d at 596. The statute places no time limits or restrictions as to when this can be done. See Id. at 594-96 (thirteen years elapsed before a QDRO was established).
Following the creation of QDROs by the Retirement Equity Act of 1984, the General Assembly amended section 452.330.5 in 1988 to include the above proviso for QDROs. Ochoa, 71 S.W.3d at 596. A QDRO allows a court to "to enforce a nonplan participant's right to `. . . marital property rights' previously granted by `any judgment, decree, or order.'" Seal v. Raw, 954 S.W.2d 681, 684 (Mo.App. 1997) (quoting 29 U.S.C. § 1056(d)(3)(B)(ii)). When a domestic relations *581 order delineates a former spouse's right to receive marital property, a court may enter a QDRO if the order satisfies the requirements of 29 U.S.C. § 1056(d)(3).[2]Id. at 685. That statute requires the order to be a "domestic relations order." § 1056(d)(3)(B)(ii). A domestic relations order is a judgment, decree, or order relating to the provision of, inter alia, marital property rights to a former spouse, and which is issued pursuant to a state's domestic relations law. Id.
In this case, the dissolution was granted prior to the 1988 amendment to section 452.330.5. The terms of the dissolution decree provide that "[Brenda] shall receive a portion of [Edward's] Retirement/Pension Plan from [his] employer, Union Pacific Railroad Company (Railroad Retirement Fund)," pursuant to a formula that factors in the length of the marriage, Edward's years of service with the Railroad, and the dollar amount of the benefit being paid.[3] The decree further states that
Petitioner [Brenda]'s share of the sums payable shall be due to her immediately if, as and when same are paid from the same plan to Respondent [Edward], or survivor or other designee, and without regard to the binding effect of this agreement upon Petitioner's (sic) employer, the said plan administrator[,] other person or entity other than [Edward].
The decree requires Edward to "sign any and all documents on behalf of [Brenda] with the . . . Railroad . . . to insure that [Brenda] shall receive the benefits as ordered herein." Edward and Brenda disagree about the intent and effect of the decree.
The circuit court's order in this case was a domestic relations order. Thus, the circuit court retained jurisdiction to establish the domestic relations order as a QDRO. This would have clarified the intent of the decree and provided proper instruction as to what benefits were intended to be awarded to Brenda. Therefore, Edward had an adequate remedy at law in which to seek redress of his complaints about the Retirement Board's division of his disability benefits. Where the petition for a declaratory judgment fails to state a claim upon which relief can be granted, the trial court lacks jurisdiction to enter judgment thereon. Lane v. Lensmeyer, 158 S.W.3d 218, 223 (Mo. banc 2005). Because our jurisdiction is derivative, In re Moreau, 161 S.W.3d at 405, we too lack jurisdiction to review this appeal on the merits, and it must be dismissed.

Conclusion
For the foregoing reasons, the appeal is dismissed. The cause is remanded with directions to vacate the judgment and to dismiss for lack of jurisdiction.
SMITH and HARDWICK, JJ., concur.
NOTES
[1]  All statutory references are to the Revised Statutes of Missouri, 2000, unless otherwise noted.
[2]  The Employee Retirement Income Security Program (ERISA), 29 U.S.C. § 1056(d)(3) sets out the requirements that a domestic relations order must meet in order to be considered a QDRO. Baird v. Baird, 843 S.W.2d 388, 391 (Mo.App.1992).
[3]  Neither party discusses whether all of Edward's railroad retirement benefits are divisible under federal law. See 45 U.S.C. § 231m; Hisquierdo v. Hisquierdo, 439 U.S. 572, 574-75, 99 S.Ct. 802, 59 L.Ed.2d 1 (1979).
