James encourages us to ask God for His wisdom because he understands we need it to become spiritually mature. In order to receive this wisdom we need to know who God is and we have to know the proper way to approach God.
God is generous. He loves to bless His people and giving is in His nature. He gives without reservation/hesitation and without reproach (He is forgiving).
There are 2 attitudes we can have that block God from giving us wisdom. If we doubt who He is (if you don't trust Him you won't truly believe/accept what he offers) and being double-minded/souled (trying to live as God's friends while placing earthly things above Him.) You need to have a full commitment to God. His wisdom will do us no good if we aren't devoted to His ways.