EHCache冲突问题解决

阅读更多
两个Springboot应用在同一台服务器上运行,用hibernate更新相同表实体记录时,发生
org.springframework.orm.hibernate4.HibernateSystemException: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 00000000; nested exception is org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 00000000
	at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:218)
	at org.springframework.orm.hibernate4.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:730)
	at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:592)
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)

异常,经过排查发现是因为ehache缺省配置是持久化硬盘的,而两个项目的cache存储路径相同,导致反序列化时发生错误。
修改ehcache.xml,设置缺省cache的diskPersistent="false"即可。

你可能感兴趣的:(cache,hibernate,java)