Hibernate NotSerializableException and ArrayStoreException in Bamboo
Problem
NotSerializableExceptions
and ArrayStoreExceptions
from Hibernate are being thrown in the Bamboo logs or UI. Generally these exceptions will not cause any visible impact but are indicative of a problem that can cause poor performance. However, these exceptions can present to the UI and affect page rendering under certain circumstances.
Diagnosis
The presence of the below WARN
level log is evidence of the Cause below:
2017-06-01 12:45:22,633 WARN [localhost-startStop-1] [ConfigurationFactory] No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/opt/atlassian-bamboo-6.0.1/atlassian-bamboo/WEB-INF/lib/ehcache-2.7.5.jar!/ehcache-failsafe.xml
Stack traces similar to the following are found in <bamboo-install>/catalina.out
or shown in the UI:
java.io.NotSerializableException: org.hibernate.persister.entity.SingleTableEntityPersister
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
...
at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399)
at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381
2017-06-12 10:15:27,791 ERROR [http-nio-8085-exec-7] [ExceptionMappingInterceptor] org.hibernate.property.access.spi.SetterMethodImpl$SerialForm
java.lang.ArrayStoreException: org.hibernate.property.access.spi.SetterMethodImpl$SerialForm
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1919)
...
at net.sf.ehcache.store.disk.DiskStore.flush(DiskStore.java:249)
...
at com.atlassian.user.impl.cache.properties.CachingPropertySetFactory$RecacheOnWritePropertySet.getString(CachingPropertySetFactory.java:263)
at com.atlassian.bamboo.user.DefaultBambooUser.getUserProperty(DefaultBambooUser.java:59)
at com.atlassian.bamboo.user.DefaultBambooUser.getJabberAddress(DefaultBambooUser.java:52)
at com.atlassian.bamboo.ww2.actions.admin.user.ConfigureUser.edit(ConfigureUser.java:145)
2017-06-12 06:46:02,313 ERROR [http-nio-8085-exec-20] [runtime] Error executing FreeMarker template
FreeMarker template error:
Java method "com.atlassian.plugin.webresource.WebResourceManagerImpl.getRequiredResources(com.atlassian.plugin.webresource.UrlMode)" threw an exception when invoked on com.atlassian.plugin.webresource.WebResourceManagerImpl object "com.atlassian.plugin.webresource.WebResourceManagerImpl@4d93d3ce"; see cause exception in the Java stack trace.
..
Caused by: java.lang.ArrayStoreException: org.hibernate.property.access.spi.SetterMethodImpl$SerialForm
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1919)
..
at com.atlassian.user.impl.cache.properties.CachingPropertySetFactory$RecacheOnWritePropertySet.exists(CachingPropertySetFactory.java:301)
at com.atlassian.bamboo.plugins.branchinator.service.UserPropertiesServiceImpl.getUserProperties(UserPropertiesServiceImpl.java:70)
at com.atlassian.bamboo.plugins.branchinator.service.UserPropertiesServiceImpl.getUserProperty(UserPropertiesServiceImpl.java:42)
Cause
Ehcache has failed to load its configuration from the Bamboo default (may include additional user customizations especially for LDAP) bundled at <bamboo-install>/atlassian-bamboo/WEB-INF/classes/ehcache.xml
and has reverted to a failsafe configuration. This failsafe configuration allows cached entities or queries to be written to disk if the memory store is full. Some of the entities are not serializable, as the Bamboo default configuration for Ehcache disables disk caching.
The failsafe configuration is loaded under the below circumstances:
ehcache.xml
is not present in<bamboo-install>/atlassian-bamboo/WEB-INF/classes
<bamboo-install>/atlassian-bamboo/WEB-INF/classes/ehcache.xml
is a symbolic link to another location.
Resolution
- Ensure
ehcache.xml
is present in<bamboo-install>/atlassian-bamboo/WEB-INF/classes
- Replace any symbolic links with an actual copy of
ehcache.xml
or a hard link