As shared in a variety of answers to the related question, the overwhelming consensus on this site is that Paul & James are not in disagreement with each other. This is my view as well (It is of course fair to point out that there are those who have argued that Paul & James are irreconcilable--Luther, for much of his life, being the most prominent example).
How to reconcile James & Paul is not the subject of the OP and has been extensively covered by other posts--but I would like to share a few thoughts specifically on the idea that one author is attacking the views of the other, and what it means for chronology.
I am particularly impressed by Mark Ellison's summary of the circumstances here.
A few points worth noting:
- Paul's focus is on countering the view that salvation comes through the works of the Law [of Moses]
- Paul is not saying that it does not matter what we do. Jesus specifically taught that what we do does matter:
Not every one that saith unto me, Lord, Lord, shall enter into the
kingdom of heaven; but he that doeth the will of my Father which is in
heaven. (Matthew 7:21)
My thoughts relevant to Matthew 7:21 are shared in greater detail in discussion here on the parable of the pearl.
One of the points Ellison makes particularly well is that while James' & Paul's teachings are not in direct conflict, it is very possible, even probable, that some of the Christians familiar with their teachings were in conflict. The confusion among the Galatians almost demands such an explanation.
It would be simplest then to conclude that either James is responding to misrepresentations of Paul's teachings (but Paul told me it doesn't matter what I do! No, he didn't), or that Paul is responding to misrepresentations of James' teachings (But James said we're saved by the works of the Law. No, he didn't), or both.
Since Paul--in both Galatians & Romans--makes a much more extensive argument, I suggest that the epistle of James came prior to either of these Pauline epistles. I have no trouble seeing Paul's writings as a thorough critique of the misuse of James; I have a much harder time seeing the brief exegesis by James as a thorough response to the misuse of Paul--were it not so, we should expect an exegesis on grace to feature prominently in a rebuttal by James.
I see in James & Galatians much that reflects the debates of the Jerusalem Council of Acts 15, and my own New Testament chronology puts both epistles in temporal proximity to the council.
Questions from the OP
Is the writer of James attacking Paul's position specially in Romans? I don't think so, but rather James is countering the misuse of Paul's teachings.
This would imply James' letter was written after Romans. We do not know with certainty, but I doubt it. Paul's dissertations on grace are written in response to Judaizers, and in Galatians he even speaks of disruption from "certain men who came from James" (Gal. 2:12), suggesting that James and his words were prominent before Paul was. Paul is writing in response to people who have misused James' words.
A plausible series of events
- Paul preaches the doctrine of grace on his first missionary journey (~ AD 46-49)
- Some take Paul out of context and use his teachings as a license for sin
- James corrects this misuse of Christian teaching in his epistle (~49)
- The Jerusalem Council addresses related issues in AD 49
- Some of the Judaizers take James out of context and use his teachings to uphold the view that salvation comes by the observance of the Law of Moses
- Paul corrects this misuse of Christian teaching in his epistle to the Galatians (~AD 49-50)
- Paul introduces his teachings to the Christians in Rome--whom he has never visited--covering much of the same ground that is still causing divisions between Jew & Gentile--in his epistle to the Romans in AD 56 or 57