I had a similar problem. When running on a JBoss server, my code worked fine, but calling it from a unit test case in an ant script gave the same exception java.lang.ClassNotFoundException: org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.
The problem turned out to be that on the server I was using JDK 1.5, which worked fine. However, the ant script was using an installed JDK 1.6. The problem was solved by removing 1.6, which I did not use.
[Message sent by forum member 'mortenheine' (mortenheine)]
http://forums.java.net/jive/thread.jspa?messageID=300007