
43 Md. App. 286 (1979)
405 A.2d 313
ANNAPOLIS URBAN RENEWAL AUTHORITY
v.
INTERLINK, INCORPORATED.
No. 1071, September Term, 1978.
Court of Special Appeals of Maryland.
Decided September 7, 1979.
The cause was argued before MOYLAN, MOORE and MACDANIEL, JJ.
Nicholas J. Fotos and Robert de V. Frierson for appellant.
Benjamin Michaelson, Jr., with whom was Mark S. Hoffmann on the brief, for appellee.
MOORE, J., delivered the opinion of the Court.
This appeal involves the falling-out between the Annapolis Urban Renewal Authority (AURA) and Interlink, Incorporated, which was selected by AURA in December 1973 *287 as the developer of Parcel #15 of the Town Center Urban Renewal Area of the City of Annapolis. The project was designated as Martin Luther King Village. Under a contract with AURA, and in conformity with certain plans and specifications, Interlink undertook to construct 22 residential townhouses on the parcel. Inevitably, disputes arose between the parties before the project was completed. In November 1974, to avoid a work stoppage, and "fight about it later on," the parties entered into an "escrow agreement," each contributing to a fund aggregating $7,948.10,[1] "pending the outcome of negotiations." Counsel for AURA, Nicholas J. Fotos, Esq., was designated as "escrow agent." Although he was not a party to the agreement, the instrument provided that the "escrow agent agrees not to disburse the funds without being so authorized by both parties ... or in the event the parties cannot agree, by order of Court or appropriate order by an arbitrator in the event the parties agree to arbitrate."
The escrow agreement  which has given rise to this appeal  apparently went into eclipse when the job was completed. Interlink sued AURA and the Mayor and Aldermen of the City of Annapolis on June 30, 1975 for damages in the amount of $100,000 for breach of contract.[2] Neither party made any reference to the escrow account in its pleadings. Eventually, AURA interposed a motion under Md. Rule 323 raising a preliminary objection  that of sovereign immunity. The Circuit Court for Anne Arundel County (Beardmore, J.), on October 18, 1976, sustained the objection, finding that AURA was an "agency of the state performing a governmental function, and that defense has not been expressly or impliedly waived." Judgment was entered for AURA. Interlink did not appeal.
*288 It appears that AURA thereafter requested Interlink's concurrence to the disbursement of the escrow money to AURA. Interlink refused. On May 19, 1977, AURA filed a declaratory judgment action, requesting that the Circuit Court for Anne Arundel County declare that it was entitled to the proceeds and interest held by the escrow agent. AURA alleged that the basis for the action was that "[t]he funds in the escrow account were part of the damages sought in [Interlink's abortive breach of contract action] and as a result of the Court's ruling and the expiration of the appeal time such damages cannot be recovered...." A motion for summary judgment, based on the theory of res judicata accompanied the declaration. The lower court (Williams, J.) denied the motion. Interlink thereafter amended its plea and prayed a declaratory judgment that it was entitled to the escrow fund.
At a subsequent court trial on the merits of the declaratory judgment action before Judge Williams, appellant called Mr. Fotos, the escrow agent, as its sole witness. Through him, it offered the record in the breach of contract action which had been dismissed by order of Judge Beardmore. It was received and appellant rested.
Interlink then called its president, Alexandria Crawford, who was followed to the stand by its vice-president, Ralph Crawford. Over AURA's objection, Interlink was permitted to relitigate the issue of breach of the 1973 contract. The court allowed the Crawfords to testify concerning the terms of the contract, the failure of AURA to provide utilities in accordance with the agreement and to reimburse Interlink for certain change orders, as well as AURA's liability under an adjustment clause of the contract for late delivery of each of three sections of the parcel of land under a settlement schedule annexed to the contract. The damages to which they testified exceeded $16,000.
At the close of all the evidence, AURA renewed its motion for summary judgment. Mr. Fotos pointed out to the court that he had not gone into a "meritorious defense" deliberately, although, he asserted, "We could prove they weren't damaged at all." He stated: "[T]his is a res judicata *289 situation.... [W]e're not asking the Court to apply the doctrine of sovereign immunity in this case, we're asking the court now for res judicata."
In an oral opinion from the bench, followed by a written declaratory judgment order, Judge Williams rejected appellant's contention that it was entitled to prevail on res judicata grounds. With respect to the merits of the declaratory judgment case, he then said:
"[T]he Court certainly has heard sufficient evidence today to indicate that Interlink has valid claims against Annapolis Urban Renewal Authority which must be considered before a disbursement of any of the escrow funds can be allowed by the Court.... [T]hese claims total well in excess of the amount held in escrow so that the Court finds that the full amount held by the escrow agent could be paid to Interlink, Inc., and none of it should be returned to AURA." (Emphasis added.)
Although on appeal AURA puts forth three separate contentions, they merge into one: that as a result of Judge Beardmore's ruling in the breach of contract suit, AURA was entitled to prevail on res judicata grounds and it was error for the court below in the suit on the escrow agreement to allow evidence bearing upon the breach of the contract and to hold that Interlink was entitled to the escrow fund, plus interest.

I
At the outset, we observe that for res judicata analysis, this case is unique. Usually the doctrine is raised by a defendant to defeat a second suit on the same cause of action initiated by the unsuccessful plaintiff in the first suit. Here, however, the defendant in the first suit, in seeking a declaratory judgment[3] as to its entitlement to the escrow account, used *290 the res judicata doctrine offensively when it rested its case on the prior judgment granted in its favor on grounds of sovereign immunity. This is indeed an unusual context in which res judicata is sought to be employed, but we do not find the situation untenable.
In Maryland and elsewhere, the doctrine of res judicata has been defined in myriad cases as:
"[A final] judgment [on the merits] between the same parties and their privies is a final bar to any other suit upon the same cause of action, and is conclusive, not only as to all matters that have been decided in the original suit, but as to all matters which with propriety could have been litigated in the first suit, where the court had jurisdiction, proceedings were regular, and his omission was due to his own negligence."
Alvey v. Alvey, 225 Md. 386, 390, 171 A.2d 92, 94 (1961). See Southland Corp. v. Shulman, 331 F. Supp. 1024, 1027 (D. Md. 1971); Maicobo Investment Corp. v. Von Der Heide, 243 F. Supp. 885, 890 (D. Md. 1965); Cook v. State, 281 Md. 665, 668-69, 381 A.2d 671, 673 (1978); MPC, Inc. v. Kenny, 279 Md. 29, 32, 367 A.2d 486, 488-89 (1977); Missler v. Anne Arundel County, 271 Md. 70, 77, 314 A.2d 451, 456 (1974); Shoreham Developers, Inc. v. Randolph Hills, Inc., 269 Md. 291, 302, 305 A.2d 465, 472 (1973); Nicholson v. Unsatisfied Claim and Judgment Fund Board, 265 Md. 453, 458-60, 290 A.2d 384, 386-87 (1972); Arundel Asphalt Products, Inc. v. Morrison-Johnson, Inc., 256 Md. 170, 173, 259 A.2d 789, 790-91 (1969); Pat Perusse Realty Co. v. Lingo, 249 Md. 33, 35, 238 A.2d 100, 102 (1968); Sterling v. Local 438, Liberty Association of Steam and Power Pipe Fitters and Helpers Association, 207 Md. 132, 140-41, 113 A.2d 389, 392-93 (1955); Klein v. Whitehead, 40 Md. App. 1, 13-14, 389 A.2d 374, 382-83 (1978); Singer v. Steven Kokes, Inc., 39 Md. App. 180, 182-83, 384 A.2d 463, 465-66 (1978); Felger v. Nichols, 35 Md. App. 182, 183-84, 370 A.2d 141, 142-43 (1977); Tucker v. Tucker, 35 Md. App. 710, 714, 373 A.2d 16, 17-18 (1977).
If a judgment is to be accorded res judicata effect, the first *291 requirement is that it be a final judgment on the merits.[4] Crucial to the resolution of the present controversy, therefore, is whether the judgment entered after the granting of the motion raising preliminary objection, pursuant to Maryland Rule 323 (a), was a judgment on the merits.
Maryland Rule 323 (a) lists ten defenses that "constitute grounds for a motion raising preliminary objection." Among these, is the defense of sovereign immunity which, unlike some of the other defenses, may be raised at any time. Md. Rule 323 (b). According to one authority, Rule 323 confers "[t]he right to interpose certain defenses which do not go to the merits of the controversy through the use of a motion restricted in its scope and filed before the parties are at issue on any question of law or fact except those specifically raised by the motion." (Emphasis added.) 3 Poe's Pleading and Practice § 75 (Sachs ed. 1975). "The purpose of [the Rule] is to have a legal question ... decided before trial of the action on its merits...." Irvine v. Montgomery County, 239 Md. 113, 117, 210 A.2d 359, 361 (1965). Although the "merits" of the underlying cause of action are never heard when a Rule 323 motion is granted on grounds of sovereign immunity, we conclude that the judgment entered is indeed a final judgment on the merits for purposes of res judicata. We shall explain.
Over the years, much scholarly debate has occurred with respect to what constitutes a judgment on the merits. In particular, a great deal of discussion has centered around the effect of various types of judgments entered without a full trial. Some are to be given res judicata effect while others are not. For example, today, in federal practice, and in most states, a dismissal, in the absence of a contrary rule or a statutory exception, is deemed to be with prejudice and on the merits.[5] A dismissal without prejudice is not, of course, an adjudication on the merits.[6] Other types of judgments even *292 though not judgments "on the merits" are given a restricted type of res judicata effect. This is the case with respect to "matters in abatement, such as jurisdiction of the subject matter, federal jurisdiction, jurisdiction over the res, jurisdiction over the defendant, venue, and related matters," where the policies of res judicata apply although there has been no adjudication on the merits in the traditional sense. 1B Moore's Federal Practice ¶ 0.405[5], at 655-56 (2d. ed. 1974). The application of the doctrine is more limited in these latter situations, in that only the relitigation of the precise issue adjudged is precluded; if the jurisdictional deficiency is removed, the substantive claim may be litigated in a subsequent action.[7]
A judgment on the merits has been defined traditionally as one which rules on "the real or substantial grounds of action or defense as distinguished from matters of practice, procedure, jurisdiction or form." Clegg v. United States, 112 F.2d 886, 887 (10th Cir.1940). See also 1B Moore's Federal Practice ¶ 0.409, at 1001-43 (2d. ed. 1974). However, as the Supreme Court stated in Angel v. Bullington:
"It is a misconception of res judicata to assume that the doctrine does not come into operation if a court has not passed on the `merits' in the sense of the ultimate substantive issues of a litigation. An adjudication declining to reach such ultimate substantive issues may bar a second attempt to reach them in another court of the State. Such a situation is presented when the first decision is based not on the ground that the distribution of judicial power among the various courts of the State requires the suit to be brought in another court in the State, but on the inaccessibility of all the courts of the State to such litigation." (Emphasis added.) *293 330 U.S. 183, 190 (1947). In Angel, the Supreme Court held that a State court's prior dismissal of an action on the ground that a State statute precluded recovery of certain types of deficiency judgments was res judicata in a second action brought in the federal courts, challenging the constitutionality of the statute. Thus, in the first action, the finding that the statute did not authorize the recovery sought prevented litigation of the main cause of action, yet, the judgment was a complete bar to the second suit based on the same cause of action.
Similarly, a dismissal of an action, for failure to state a cause of action has been held to be a judgment on the merits.[8] As was held in Bell v. Hood:
"[I]t is well settled that the failure to state a proper cause of action calls for a judgment on the merits and not for a dismissal for want of jurisdiction. Whether the complaint states a cause of action on which relief could be granted is a question of law and just as issues of fact it must be decided after and not before the court has assumed jurisdiction over the controversy. If the court does later exercise its jurisdiction to determine that the allegations in the complaint do not state a ground for relief, then dismissal of the case would be on the merits, not for want of jurisdiction."
327 U.S. 678, 682 (1946).
Bell illustrates a useful distinction  one to which we previously have alluded  as to when judgments that do not derive from the substantive issues or merits of a case, nonetheless are to be considered an adjudication on the merits and a complete as opposed to a limited bar to further *294 litigation.[9] When a court dismisses an action because of jurisdictional, procedural, or venue problems, it is acting for reasons that do not go to the substance of the case. But, when a court decides that it cannot hear the case because of a legal defense such as sovereign immunity, it is deciding that, as a substantive matter, the plaintiff cannot maintain his cause of action.
The case of Weston Funding Corp. v. Lafayette Towers, Inc., 550 F.2d 710 (2d Cir.1977), is illustrative and supportive of this position. There, the New Jersey legislature had enacted a law which barred suits brought in New Jersey courts by real estate brokers seeking commissions if the brokers were not licensed in New Jersey. Pursuant to this law, the federal district court in New Jersey had granted summary judgment against the appellant broker. He did not appeal, instead choosing to institute a new action in the federal district court in New York. That court held that the first unappealed judgment was res judicata to the second action. The Second Circuit affirmed this determination, stating in part:
"It is true that summary judgment was granted in the New Jersey action necessarily before `the defendant [had to] incur the inconvenience of preparing to meet the merits' of Weston's claim at trial. Costello v. United States, 365 U.S. 265, 286 (1961). The Supreme Court in Costello focused on that consideration as a central factor in the determination of whether a dismissal is for lack of jurisdiction, one of the enumerated exceptions to the general rule, and therefore not on the merits.

But there are other critical factors to consider in determining whether a dismissal is on the merits. The primary one here is whether the court's reason for dismissal was that plaintiff had no cause of *295 action. In Costello the dismissal was for failure of the government to file an affidavit of good cause in a denaturalization proceeding; that failure did not destroy the underlying cause of action but simply constituted nonfulfillment of a prerequisite to the initiation of the proceedings. 365 U.S. at 268.
In contrast, N.J.S.A. § 45:15-3 is intended to bar creation of the debt, not merely to create a precondition to suit. It is not a jurisdictional or procedural provision, see Szantay v. Beech Aircraft Corp., 349 F.2d 60, 63-64 (4 Cir.1965), but an expression of a significant substantive policy of the state. Stahl v. Township of Teaneck, 162 F. Supp. 661, 667-69 (D.N.J. 1958)." (Emphasis added.)
Id. at 713-14.
Like the statutory policy recognized in Weston, we believe that the legal defense of sovereign immunity represents a "significant substantive policy of [a] state," and a judgment based upon the defense is a judgment on the merits. This position finds support in the case of Gissen v. Tackman, 401 F. Supp. 310 (D.N.J. 1975), vacated on other grounds, 537 F.2d 784 (3d Cir.1976). In Gissen, the first case was dismissed pursuant to Fed.R.Civ.P. 12 (b) (6), because of the immunity of the defendants as federal officials. This judgment was determined to be an adjudication on the merits which barred a second action on the same cause of action. The court held as follows:
"It is clear that a judgment is `on the merits' where the substance of the claim, as distinguished from matters of practice, procedure, jurisdiction or form, has been determined. Clegg v. United States, 112 F.2d 886, 887 (10th Cir.1940); see Etten v. Lovell Mfg. Co., 225 F.2d 844, 846 (3d Cir.1955); Restatement of Judgments § 49 (1942). Where the Court merely holds that there is some technical or procedural reason why the plaintiff cannot recover on his cause of action, the judgment is not deemed *296 to be `on the merits'. Dismissals by reason of lack of jurisdiction or improper venue are examples of those judgments which have consistently been held to be `not upon the merits'. Smith v. McNeal, 109 U.S. 426, 3 S.Ct. 319, 27 L.Ed. 986 (1883); Etten v. Lovell Mfg. Co., supra.

* * *
It is well settled that a judgment dismissing a complaint pursuant to Fed.R.Civ.P. 12 (b) (6) is presumed to be on the merits for res judicata purposes, unless the contrary appears on the record. In a subsequent suit on the same claim the judgment has the same effect as if it was rendered after trial. See Bartsch v. Chamberlin Co., 266 F.2d 357 (6th Cir.1959); 1B Moore, Federal Practice ¶ 0.409[1] (2d ed. 1942).
Since the order of dismissal in Gissen I was not based upon lack of jurisdiction (as in the case of Miller v. Saxbe) or improper venue, and did not specify that it was not upon the merits, it operated as an adjudication upon the merits sufficient to allow the application of the doctrine of res judicata. See Bartsch v. Chamberlin, supra."
Id. at 311-12.
Applying the above enunciated principles, we conclude that the judgment entered in this case pursuant to the granting of the motion raising preliminary objection, was a final judgment on the merits. To hold that the first judgment was res judicata to the second action, however, we must satisfy also two additional requirements: (1) the cases must involve the same parties or their privies; and (2) the cause of action in each suit must be the same. It is obvious that the first requirement has been fulfilled. With respect to the second, the test, in Maryland, for determining whether, for res judicata purposes, the causes of action are the same was expressed by Judge Levine in MPC, Inc. v. Kenny:
"Courts elsewhere have applied a variety of tests in determining whether two causes of action are the *297 same for purposes of invoking res judicata. The measure which seems to find favor with most courts, and one which we have applied, is whether the same evidentiary facts would sustain both actions." (Citations omitted.) (Emphasis added.)
279 Md. at 33; 367 A.2d at 489.
In the instant case, applying the "same evidence" test, we think it plain that the breach of contract action by Interlink and the declaratory judgment action by AURA, in which Interlink also prays a declaratory judgment, are the same. Undeniably, the evidence received below in support of Interlink's entitlement to the escrow fund, was the same evidence  even if not all  which would have sustained its breach of contract action, had it proceeded on the merits.
The net result is, in our judgment, that the defense of sovereign immunity, whether correctly decided by Judge Beardmore or not,[10] precludes Interlink from relitigating the breach of contract claims in the declaratory judgment suit. We cannot agree with the trial court that AURA waived this defense by entering into the escrow agreement. Sovereign immunity cannot be waived unless pursuant to express statutory authority.[11]Board of Education v. Alcrymat Corp., 258 Md. 508, 516, 266 A.2d 349, 353 (1970).
Appellee could have challenged on appeal the correctness of the first determination but decided not to pursue an appeal. It now cannot be permitted to argue error in the prior determination. "The doctrine of res judicata does not depend *298 on whether the prior judgment was free from error." Mitchell v. National Broadcasting Co., 553 F.2d 265, 272 (2d Cir.1977).
Judgment reversed; each party to pay its own costs.
NOTES
[1]  The funds comprising the escrow account consisted of: a) $4,648.10 representing the balance owed to the appellant by the appellee pursuant to the contract and paid into escrow by or on behalf of Interlink; and b) $3300 representing one of the amounts in dispute for sewer and water taps and the cost of a building permit from the City of Annapolis and paid into escrow by AURA.
[2]  An amended declaration was filed on January 10, 1976 and a second amended declaration on June 17, 1976. None of these pleadings made reference to the escrow agreement. The ad damnum was reduced in the second amended declaration to $84,925.75.
[3]  In a declaratory judgment action, whether it be at law or in equity, the court has jurisdiction to "declare rights, status, and other legal relations whether or not further relief is or could be claimed." Md. [Cts. & Jud. Proc.] Code Ann. § 3-403 (1974 & Supp. 1978).
[4]  See Restatement of Judgments § 48 (1942).
[5]  See Fed.R.Civ.P. 41. Compare Moodhe v. Schenker, 176 Md. 259, 267, 4 A.2d 453, 457 (1939) (judgment on demurrer is conclusive as an adjudication on the merits unless "the demurrer is directed to formal and technical defects apparent upon the face of the bill.").
[6]  Williams v. Snyder, 221 Md. 262, 266-67, 155 A.2d 904, 906-07 (1959).
[7]  See Acree v. Air Line Pilots Assoc., 390 F.2d 199, 203 (5th Cir.), cert. denied, 393 U.S. 852 (1968); Miller v. Saxbe, 396 F. Supp. 1260, 1261 (D.D.C. 1975); Luker v. Nelson, 341 F. Supp. 111, 114-15 (N.D. Ill. 1972). See generally, 1B Moore's Federal Practice ¶ 0.405[5], at 655-63 (2d ed. 1974); Restatement of Judgments § 49 (1942).
[8]  In federal practice, such a dismissal is pursuant to Rule 12 (b) (6). See generally 1B Moore's Federal Practice ¶ 0.409[1], at 1005-08 (2d ed. 1974). Maryland Rule 323 "is patterned after Federal Rule 12(b) but is broader in its scope, some defenses not being available under the Federal rule having been included in the Maryland rule. 3 Poe's Pleading and Practice § 75C, at 87 (6th ed. Sachs 1975).
[9]  Because many of the judgments which are deemed to be on the merits for res judicata purposes do not pass "directly on the substance of the claim," the Restatement Second of Judgments deleted the "on the merits" language to prevent "possibly misleading connotations." § 48, comment a, at 36 (Tent. Draft 1973).
[10]  Judge Williams indicated disagreement with the holding that AURA had sovereign immunity. See American Structures, Inc. v. City of Baltimore, in which the Court of Appeals stated:

"Municipalities and counties have been regularly subject to suit in contract actions, whether the contracts were made in performance of a governmental or proprietary function, as long as the execution of the contract was within the power of the governmental unit."
278 Md. 356, 359-60, 364 A.2d 55, 57 (1976).
[11]  The escrow contract was entered into in November 1974, prior to the effective date of Chapter 450 of the Acts of 1976 which removed the defense of sovereign immunity to suits against the State based on written contracts.
