Unfortunately, this happens more than it should.
If your Ex-wife will amend and admit the error, then you can file after that. Otherwise, you have to do a paper return.
The IRS does not allow you to e-file a return with a dependent's SSN that has already been accepted and processed, even if the other taxpayer was not entitled to the exemption.
You will need to print out and mail the return, and attach an explanation that the dependent was claimed in error on another return.