[SalesForce] ANT migration tool BUILD FAILED : Failed to login

So I installed ANT in my machine today and trying to play around with it. I'm trying to run my first command ant retrieveUnpackaged from the sample folder of salesforce and I'm getting the following error.

BUILD FAILED

Failed to login: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'.

so I used ant -verbose to dig deeper and it seems like my task definitions were not found. This was my main error in the command prompt.

Could not load definitions from resource

com/salesforce/antlib.xml

Would anyone throw some light on what that issue means and how to resolve it please?

Best Answer

I faced this error when i try to authenticate the callouts with username and password with invalid credentials. Please double check your credentials you use for connecting org.

Explanation for inappropriate error message:

When you try to login to any site, if your credentials are wrong it show you 'Invalid credentials'. But originally it returns a html document which have a text 'Invalid credentials' along with other html components.

The same happens via SOAP login as well. If successful login it returns SOAP messages. If unsuccessful login it returns the html document which having text like 'Invalid credentials'.

But our tool expects specific format but got html. So it throws

Unexpected element. Parser was expecting element http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'

Hope it helps you to understand better.