someOriginally Originally posted here: https://forum.hibernate.org/viewtopic.php?f=1&t=1043534&e=0 and http://stackoverflow.com/questions/38980894/wildfly-clustering-and-hibernate.
An AbstractPersistentCollection will throw a NullPointerException if an object contains a lazy loaded collection where the encapsulating objected is loaded on one server, then replicated to another server, where the getter is called in a clustered environment.
Here's an example:
{code} @Table(name = "[User]") @Entity public class User extends CommonDomainBase {
@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true, mappedBy = "user", fetch = FetchType.LAZY) private List<UserSearchingPreference> searchingPreferences;
public List<UserSearchingPreference> getSearchingPreferences() { return searchingPreferences; } } {code}
In a clustered environment, in a web application which supports distributable, on wildfly 10, with let's say 2 servers. If User is loaded on server one, and placed into the session, if retrieved on server 2, an invocation of getSearchingPreferences() will throw the null pointer as the uuid of the hibernate session factory is serialised within the AbstractPersistentCollection, but refers to the factory on server one, not server 2.
The proposed solution from smarlow is to use the factory name over the id. |
|