Count it all joy, my brothers, when you meet trials of various kinds, for you know that the testing of your faith produces steadfastness. And let steadfastness have its full effect, that you may be perfect and complete, lacking in nothing. (James 1:1–4, ESV)
That first line is a tough one to swallow. "All joy"? Some translations say "pure joy." Really, James? Do you mean that I am to be filled with joy when the pain of life and circumstances comes knocking at my door? Yes, that's what he's saying. The joy comes from knowing, not that something awful happened, but that an awfully loving God is up to something good in the midst of this despairing time.
He tells us specifically when our faith is tested that it produces steadfastness (patience, endurance and fortitude). Many of us understand the importance of the process that a butterfly has to go through to emerge from the cocoon. If he is robbed of the opportunity to struggle, he will die. He must go through the difficult and slow battle of breaking out of his temporary home so that he will be strong enough to be what God created him to be.
Trials are what God uses to make us into the kind of men and women he wants us to be. None of us welcomes the "cocoons" of life, but we all know that they are necessary. Welcome God's testings into your life. Let them have their full effect. When you finally break through and emerge from the pain, you will be stronger, more mature and able to fly like never before.