(a) A party waives all defenses and objections which are not presented either by preliminary objection, answer or reply, except a defense which is not required to be pleaded under Rule 1030(b), the defense of failure to state a claim upon which relief can be granted, the defense of failure to join an indispensable party, the objection of failure to state a legal defense to a claim, the defenses of failure to exercise or exhaust a statutory remedy and an adequate remedy at law and any other nonwaivable defense or objection.(b) Whenever it appears by suggestion of the parties or otherwise that the court lacks jurisdiction of the subject matter or that there has been a failure to join an indispensable party, the court shall order that the action be transferred to a court of the Commonwealth which has jurisdiction or that the indispensable party be joined, but if that is not possible, then it shall dismiss the action.