James 5:16
How can the prayer of a righteous man avail if Paul says there are no righteous men?
The answer is clear when the contexts of these statements are considered. In the Romans passage, Paul is reaching the climax of his argument in chapters 1-3, that man on his own is not righteous before God, that Jew and non-Jew alike are not worthy on the basis of their works and merits to be justified before God. In this sense Paul says that nobody is righteous. Yet Paul goes on to show that through faith in Jesus Christ, God-Incarnate, we are justified and therefore righteous in God's eyes. That is the glorious theme that pervades the epistle to Rome.
In the James passage, the context indicates that the man making the prayer is indeed justified and in the Church, that is, he is righteous—justified in God's sight. James in 5:7 refers to the readers as adelphoi, brothers in the faith. These addressees are indeed righteous through faith in Christ, hence James is justified with his comment in 5:16. Yet at the same time, on their own merits alone (as in Romans 1-3) the addressees are not righteous.