Its important to see who James is writing to . Its to the 12 tribes , so I think applying James to the church in total is a mistake .
Similarly Peter and John were also writing to Israel in their letters after James.
The key to understanding James's view of being right with God is that, for the nation Israel, their sins are only blotted out at Jesus's 2nd coming for them.
The backdrop is given by Peter whom the Holy Spirit was using to address Israel in Acts 3
14
But ye denied the Holy One and the Just, and desired a murderer to be granted unto you;
15
And killed the Prince of life, whom God hath raised from the dead; whereof we are witnesses.
....
19 Repent ye therefore, and be converted, that
your sins may be blotted out, when the times of refreshing shall come from the presence of the Lord.
20
And he shall send Jesus Christ, which before was preached unto you:
21 Whom the heaven must receive until the times of restitution of all things,
which God hath spoken by the mouth of all his holy prophets since the world began.
The Holy Spirit was announcing to Israel the good news that, even though they have done a wicked act in crucifying their Messiah that was promised to them in the OT, forgiveness was at hand.
All their sins will be blotted out at the times of refreshing, when Jesus comes back to the Mount of Olives for the nation, as promised in the OT.
Once you can understand that, for Israel, they will only be redeemed during the 2nd coming, everything James, Peter and John was writing in their letters will make so much more sense.
Israel's responsibility now is to stay faithful and do works (James 2), endure the coming Tribulation which is the 70th week of Daniel (1 Peter), and love God and their neighbors (1 John).
In this aspect 1 Peter 4 is especially enlightening in teaching us how Israel is to view the 7 year Tribulation
12
Beloved, think it not strange concerning the fiery trial which is to try you, as though some strange thing happened unto you:
13 But rejoice, inasmuch as ye are partakers of Christ's sufferings; that, when his glory shall be revealed, ye may be glad also with exceeding joy.
14 If ye be reproached for the name of Christ, happy are ye; for the spirit of glory and of God resteth upon you: on their part he is evil spoken of, but on your part he is glorified.
15 But let none of you suffer as a murderer, or as a thief, or as an evildoer, or as a busybody in other men's matters.
16 Yet if any man suffer as a Christian, let him not be ashamed; but let him glorify God on this behalf.
17 For the time is come that judgment must begin at the house of God: and if it first begin at us, what shall the end be of them that obey not the gospel of God?
18 And if the righteous scarcely be saved, where shall the ungodly and the sinner appear?
19 Wherefore let them that suffer according to the will of God commit the keeping of their souls to him in well doing, as unto a faithful Creator.
Vs 18 is very enlightening when I came across it for the first time.
According to Peter, there is no such thing as OSAS. Even one who is righteous can scarcely be saved, which is not what Paul would instruct us in the Body of Christ.
So if Peter can tell us that, what James is saying in chapter 2 is really not surprising. There is no need for any of us former gentiles in the Body of Christ to try to force James to agree with Paul. James is referring to Israel who have no guarantee of their salvation until Jesus returns for them.