I'm setting up a cluster of wildfly instances to run my application. It's using hibernate for its persistance.
I'm working from the infinispan config from standalone-ha.xml, jgroups I've altered to use tcp ping instead as I cannot use multicast in my environment.
Session replication is working perfectly, my mod_jk load balancer is not using sticky sessions and both of the servers in the cluster (only testing with 2) are serving up pages successfully.
I am experiencing an intermittent issue with hibernate however:
Code:
2016-08-16 10:14:47,518 INFO [stdout] (default task-8) Caused by: java.lang.NullPointerException: null
2016-08-16 10:14:47,518 INFO [stdout] (default task-8) at org.hibernate.collection.internal.AbstractPersistentCollection.openTemporarySessionForLoading(AbstractPersistentCollection.java:274)
2016-08-16 10:14:47,518 INFO [stdout] (default task-8) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:201)
2016-08-16 10:14:47,519 INFO [stdout] (default task-8) at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:546)
2016-08-16 10:14:47,519 INFO [stdout] (default task-8) at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:133)
2016-08-16 10:14:47,519 INFO [stdout] (default task-8) at org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:277)
I'm using wildfly 10, which is running hibernate 5.
Source of the class in question:
http://grepcode.com/file/repo1.maven.or ... ding%28%29The class is used for lazy loaded lists (with a one to many relationship), among other things.
Here's some of the code:
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;
}
}
From what I can see, the sessionFactoryUuid will be serialised when. So if the User is loaded on server 1, replicated to server 2, and a different request which hits server 2 attempts to call getSearchingPreferences() the sessionFactoryUuid which relates to the hibernate session on server 1 cannot be used to lookup the session on server 2, because it won't exist.
Is anyone able to confirm if I'm correct in my assumption and suggest a solution?
I'm not sure whether this is some hibernate configuration that needs adjusting, or if I should be in some way detaching objects before they are replicated.