I have an application that basically calls several web services, saves the data received from these web services, and transfers them to the user. I have an asynchronous task that calls all web services, and looks something like this:
List<Promise> t = new ArrayList<Promise>() def TIMEOUT_TIME = 6 t[0] = task { def responseFrom0 = webserviceRequestService.getResponse(0) if(responseFrom0){ return responseFrom0 } } t[1] = task { def responseFrom1 = webserviceRequestService.getResponse(1) if(responseFrom1){ return responseFrom1 } }
The getResponse action looks something like this:
List<ResponseResult> result = new ArrayList<TravelQuote>() try { wsClient = prepareRequestMap() wsResponse = externalWebservice.getQuotes(wsClient) wsResponse.responseList.each { ResponseResult responseResult = new ResponseResult() //populate properties of ResponseResult responseResult.save(failOnError:true, flush:true) result.add(responseResult) } } catch(Exception e){ log.error e.message e.printStackTrace() } return result
And in the end, I collect all the answers from all the web services, like this:
result.each { if(it){ try{ it=it.merge() }catch (Exception e){ log.error("Error occured while merging responses... : ${e.message}") } } }
Now the problem is that I get this exception from the last block of code
Property
not-null refers to a null or transient value: ResponseResult.dateCreated; The nested exception is org.hibernate.PropertyValueException: the null-null property refers to a null value or a transition: ResponseResult.dateCreated
DateCreated comes from this class, which I implemented on all my domain classes.
abstract class AbstractPersistentObject implements Serializable{ static final long serialVersionUID = 1L; Date dateCreated Date lastUpdated }
The strange thing about this problem is that it only happens in a production environment, no matter what I do, I cannot reproduce it in other environments. And also, as soon as this happens, the server simply throws this particular problem every time this code is run before the server restarts. After rebooting, this code works fine.
I'm running out of ideas, who has ideas?