Every defense, in law or fact, to a claim for relief in any pleading, whether a claim, counterclaim, cross-claim or third-party claim, shall be asserted in the responsive pleading thereto if one is required, except that the following defenses shall be made by motion: (1) lack of jurisdiction over the subject matter, (2) lack of jurisdiction over the person, (3) improper venue, (4) insufficiency of process, (5) insufficiency of service of process, (6) failure to state a claim upon which relief can be granted, (7) failure to join an indispensable party, (8) another action pending between the same parties for the same cause. If a pleading sets forth a claim for relief to which the adverse party is not required to serve a responsive pleading, the adverse party may assert at the trial any defense in law or fact to that claim for relief. If, on a motion asserting the defense numbered (6) to dismiss for failure of the pleading to state a claim upon which relief can be granted, matters outside the pleading are presented to and not excluded by the court, the motion shall be treated as one for summary judgment and disposed of as provided in Rule 56, and all parties shall be given reasonable opportunity to present all material made pertinent to such a motion by Rule 56.