NullPointerException in AbstractPersistentCollection after serialization

Description

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:

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.

Environment

None

Status

Assignee

Unassigned

Reporter

Martin Cassidy

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Priority

Major
Configure