I was able to find the cause of the issue, the particular site collection is part of a farm that was not updated and does not include the February 2015 cu update.
So I had to build a method to support both scenarios, if the getList() method is not available it will do the fall back method and will use the older method get_lists().
I ended up doing this because easier for an end user to get the list url instead of the list name.
Here is my code it might be useful if you need to deal with non updated SharePoint farms.
function custom_getListOnUrlName(listSiteUrl, listUrl, listName) {
try {
var clientContext = new SP.ClientContext(listSiteUrl);
var oList = clientContext.get_web().getList(listUrl);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Title" Ascending="True"/></OrderBy></Query></View>');
var listItems = oList.getItems(camlQuery);
clientContext.load(listItems);
clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded),
Function.createDelegate(this, onQueryFailed));
} catch (err) {
try {
onQueryFailed(listName);
}
catch (err) {
console.log('Unable to get data from list');
}
}
}
function onQuerySucceeded(sender, args) {
parseItems();
}
function onQueryFailed(listSiteUrl, listName) {
try {
var clientContext = new SP.ClientContext(listSiteUrl);
var web = clientContext.get_web();
var list = web.get_lists();
var targetList = list.getByTitle(listName);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Title" Ascending="True"/></OrderBy></Query></View>');
var listItems = targetList.getItems(camlQuery);
clientContext.load(listItems);
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFallBackFailed);
}
catch (err)
{
onQueryFallBackFailed();
}
}
function onQueryFallBackFailed(sender, args) {
console.log('Unable to get data from list');
}