We are getting a NullPointerException in clustered 2LC on EAP 6
Issue
We are currently using a Hibernate second-level cache for some of our object trees. We are seeing a case where we get an NPE in certain cases, and we are trying to nail down the root cause.
The payload validation errors in the hibernate_server.log file are due to the test we are running; both valid and invalid input are provided to the test, and all are handled as expected. The text to search for is "NullPointerException".
We do not use a persistence.xml file. I will attach standalone.xml - could you please let me know what other server configuration files you will need?
Here is the allowedValues declaration:
/**
* The set of allowed values for this configuration field.
*/
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "nep_config_field_allowed_value", joinColumns = @JoinColumn(name = "field_id"))
@Column(name = "allowed_value", length = ConfigurationFieldData.MAX_DEFAULT_VALUE_LENGTH, nullable = false)
private Set<String> allowedValues = new HashSet<>();
This is used in the hashCode() implementation as follows:
public int hashCode() {
return new HashCodeBuilder().appendSuper(super.hashCode()).append(allowedValues).toHashCode();
}
Stacktrace:
Caused by: java.lang.NullPointerException
at org.hibernate.engine.internal.StatefulPersistenceContext.getLoadedCollectionOwnerOrNull(StatefulPersistenceContext.java:859) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.event.spi.AbstractCollectionEvent.getLoadedOwnerOrNull(AbstractCollectionEvent.java:75) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.event.spi.InitializeCollectionEvent.<init>(InitializeCollectionEvent.java:36) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1847) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:549) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:234) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:545) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:124) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.hibernate.collection.internal.PersistentSet.hashCode(PersistentSet.java:428) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.apache.commons.lang3.builder.HashCodeBuilder.append(HashCodeBuilder.java:850) [commons-lang3-3.1.jar:3.1]
at test.provisioning.configuration.domain.EnumConfigurationField.hashCode(EnumConfigurationField.java:122) [nep-provisioning-service-2.0.0-GA.jar:]
at java.util.HashMap.hash(HashMap.java:366) [rt.jar:1.7.0_40]
at java.util.HashMap.put(HashMap.java:496) [rt.jar:1.7.0_40]
...
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:283) [hibernate-entitymanager-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:123) [spring-data-jpa-1.2.0.RELEASE.jar:]
...
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
