James begins by looking at our response to trials. He first states the general principle: we should find joy in our trials because they gain for us perserverence--but only if we pray for wisdom without doubting. So, we have to know how to negotiate our trials in specific ways, not just in general. We need light on how to find joy in this trial, not just trials in general. So, we need the gift of wisdom, which God gives generously.
I was recently involved in trying to promote the Church's pro life message in very difficult and somewhat antagonistic situation. My partner and I were simply stymied on how to proceed. Finally, it came to us that we should approach the Blessed Mother, the Seat of Wisdom in a novena of Rosary to find the correct path to proceed. With the gift of Wisdom that she will give us (her Son), we will be at peace and experience joy, even though our situation is difficult, because we will know we are on the right path, even if that path leads to the Cross.