Justification is one of those words that has both a theological definition, as well as a lexical definition.
From Theopedia:
Justification is the doctrine that God pardons, accepts, and declares a sinner to be "just" on the basis of Christ's righteousness (Rom 3:24-26; 4:25; 5:15-21) which results in God's peace (Rom 5:1), His Spirit (Rom 8:4), and salvation. Justification is by grace through faith in Jesus Christ apart from all works and merit of the sinner (cf. Rom 1:18-3:28).
The above is correct and I agree. But there's also the lexical definition of Justification which is much more broad.
From Mounce Greek Dictionary:
a making right or just; a declaration of right or justice; a judicial sentence; in NT, acquittal, acceptance, justification.
When approaching this word in Scripture it's imperative we start with the lexical definition and look at the context to see how the word issued. The lexical definition has a wider range of use and we can't always cram the theological definition into every occurrence of the word.
Most of the usage of this word in James has to do with the justification of a claim before men, not justification of sins before God. The early readers of this passage would have had no problem understanding what James was talking about as they didn't have the modern theological definition, which is speaking of a specific context of the term.
Luther actually rejected the book of James over this misunderstanding, but the early Church knew better. But once you separate the theological definition from the lexical, the confusion disappears.