I've encountered a peculiar issue. When making a REST call in Angular (using an app built with Ionic v1) to a Java endpoint, something goes awry and Chrome throws the following error: https://i.sstatic.net/1sxp7.png
The code of interest is this AngularJS REST service:
bankaccountsbyuser: function(_getbauser, _error){
var currentToken = _GetToken();
if(currentToken!=null){
var Headers = {
token: currentToken.tokenUser,
};
}
_timerTokenControl(currentToken, _error);
if (setupTime == null) {
console.log("token scaduto");
//$window.location.href="login.html";
}
if (currentToken !== null) {
$http({
method : 'GET',
headers: Headers,
url : REST_URL+'bankaccount'
}).then(function successCallback(response) {
console.log(response)
_getbauser(response)
}, function errorCallback(response) {
console.log(response.statusText);
});
} else {
var alertPopup = $ionicPopup.alert({
title: 'Accesso negato!',
template: 'Devi essere un utente registrato, non sei loggato!'
});
console.log("NON SEI LOGGATO!!!");
}
},
debug: https://i.sstatic.net/u7LYM.png
The GET REST service returns an error as shown above, let's examine the corresponding Java REST service:
package it.jack.fdd.services;
import java.util.List;
...rest of content...
return balist;
}
To simplify testing, I passed the number "1" into the method which is implemented below:
package it.jack.fdd.dao.impl;
import java.util.List;
...rest of content...
@Override
public List<BankAccount> getBAByUserId(int id) {
try{
Session session = HibernateUtilLezione.openSession();
Transaction tx = session.beginTransaction();
@SuppressWarnings("unchecked")
List<BankAccount> accounts = session.createQuery("from BankAccount b "
+ "where b.user= "+id).list();
tx.commit();
session.close();
return accounts;
}
catch(HibernateException e){
e.printStackTrace();
return null;
}
}
}
Upon executing the method in Java with ID 1, it returns a single record as expected.
[it.jack.fdd.domain.BankAccount@4f8d86e4]
However, when accessing this REST call in Postman, the result is different:
https://i.sstatic.net/obExc.png
Mysteriously, Postman displays the same outcome for another previously functional REST call, though this isn't an issue within the application itself but only in Postman. On the contrary, using Advanced REST Client yields a bizarrely repetitive list, almost like a loop. Any ideas on what might be causing this and how to resolve it?