This problem is most probably caused due to the classloaders in mx5. Probably one class is loaded by the runtime and the other by your userlib, causing the incompatibility. The cause of this is having either to many or to few jar files in your userlib. Best is to figure out in which jars these two classes are defined and then either remove or add them to your userlib. (yes, I am aware this is a bit vague, it is trial and error)
Note btw that you don't have to write your own http connection code, a lot of utility methods for making HTTP calls are available in the RestServices module.
Thanks solved it