Let me now offer a response to my question, "In what sense, if any, can it be said that a man acts in accordance with the virtue of justice when he mistakenly fails to give to another his due?"
Well, again, "Justice is the moral virtue that consists in the constant and firm will to give their due to God and neighbor." As St. Thomas puts it, justice is in the will. It's the habit of choosing the right thing to do as the right thing to do.
Imagine a judge who settles questions by using a Magic 8 Ball he bought at a local toy store. He does this because it's easier than trying to figure out all those laws and stuff. He does not act with justice, even when his decision does happen to give their due to the parties before him, because he is not choosing to do what he does because what he does is the right thing to do.
Now suppose that Magic 8 Ball is actually magic (or, if you prefer, guided by an angel), that to every yes-or-no question that has a correct answer it gives the correct answer. Then in every instance the judge would be giving the parties their due, but he still wouldn't be a just judge -- that is, he still wouldn't possess the virtue of justice, because he still wouldn't be choosing to act according to what is due to the parties.
As a final wrinkle, suppose the judge was for whatever reason morally certain that the Magic 8 Ball gave the correct answer to every yes-or-no question that has a correct answer. In this case, he consults it because he knows it will tell him how to act in order to give to the parties their due. He chooses to do what he does because it is the right thing to do.
Where I'm going with this, of course, is that the question of whether the judge "acts justly" in the sense of giving what is, in fact, due the parties involves is not the same as the question of whether the judge "acts justly" in the sense of willing to give what is due the parties. If the judge chooses to give to the parties what he judges is their due -- whether his judgment is based on faith in a Magic 8 Ball or on a free and full confession -- then he is acting in accordance with the virtue of justice.
And if he's wrong? Then his error lies not in the will, which is constantly and firmly directed toward choosing to give the parties their due, but in the intellect, which for whatever reason muffed the determination of what is due the parties.
This doesn't entirely settle the question, since I'm left with the case of the well-meaning fool who is wrongly convinced his Magic 8 Ball is magical. Surely there's a stronger connection between willing to give their due to God and neighbor and actually giving them their due.
But if we were to insist that the former, the willing to give others their due, counts for nothing, then we would essentially get rid of justice as a concept we can talk about. To answer the question, "Is it just?" would require a logical certainty unavailable in the real world, and in the theoretical case we would have to say the judge with the magic Magic 8 Ball always acted justly.