Problem detected!
The remote service tried to throw an Exception by encapsulating the String assembly from HashMap.values() :
if (!identifiersMap.isEmpty()) { context.setRollbackOnly(); BusinessException e = new BusinessException(); e.setValues(identifiersMap.values()); // here is where the problem is throw e; }
HashMap has an inner class called Values (as you can see here) , which is an implementation of Collection and is NOT Serializable. Thus, by creating an exception that has the contents of HashMap.values() , the remote method throws a serialization exception instead!
ArrayList, for example, is Serializable and can be used to solve a problem. Work code:
if (!identifiersMap.isEmpty()) { context.setRollbackOnly(); BusinessException e = new BusinessException(); e.setValues(new ArrayList(apIdentifiersMap.values())); // problem fixed throw e; }
In my case, the remote method was invalid and it threw an exception, but note:
This will also happen if the remote service returns an instance of HashMap $ Values, for example:
return hashMap.values();
Once again, the solution will be:
return new ArrayList(hashMap.values());
falsarella
source share