I can't speak about boys; however, my daughter refused to poop in the potty well into her 3rd year. It was clearly a control thing with her - control as to when she got special attention from me or my DH was what I was noticing.
One day I was so exasperated because she hadn't had a wetting accident for months; but, refused to poop in the potty, even when I went went with her, read books, been there done that on all the tricks and rewards. So, I told her she had to change herself and clean her own bottom because she was no longer a baby. Oh, my goodness, she was devastated. She did it - but, with great dissatisfaction. Of course I helped assure she was clean after she did the initial "cleaning" (i.e., put the poop in the toilet, flush, wash the dirty underwear out, and wipe herself clean, flush, followed by lots of washing).
That night just after my DH walked in she pooped in her pants and said "Daddy, I pooped, change me!" I informed him that she was now in charge of changing herself. (he got over the shock) After a fit and a repeat of the previous event...She never pooped in her pants again - never - and has been so proud of it, I might add.
Sounds harsh, and a bit bio-hazard-like; however, when all else fails - we have to get creative and go with our instincts.
Good Luck to you!