The only answer we found to this, after many support emails to RedHat was to change the GUID type to a string.
ClassCastException with JBoss cache
-
30-06-2022 - |
Vra
We're using JBoss SOA 5.3.1 with JBoss-cache with a hibernate 2nd level cache.
- All works fine for simple entites, except for a nested type com.example.GUID;
- GUID lives in a CommonUtil.jar, which is included in each ESB.
- Other nested values, like Joda DateTime instances work fine between ESBs, but the joda-time.jar lives in the central JBoss/lib folder, and thus a global class-loader is used.
- The problem occurs when an ESB tries to retrieve a value from the cache another ESB has previously loaded, because the cached GUID class type is a different instance a ClassCastException is thrown when Hibernate tries to call setGuid() using it.
- I've tried setting hibernate.cache.use_structured_entries = true, but this does not fix the issue
My question is, how can we configure JBoss cache and/or jboss-classloading.xml to share this auxiliary non-entity class GUID between ESBs to avoid the problem.
The exception
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.example.Equipment.guid
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:127)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:351)
at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:232)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3690)
at org.hibernate.cache.entry.CacheEntry.assemble(CacheEntry.java:139)
at org.hibernate.cache.entry.CacheEntry.assemble(CacheEntry.java:105)
at org.hibernate.event.def.DefaultLoadEventListener.assembleCacheEntry(DefaultLoadEventListener.java:587)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:542)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:397)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:908)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:876)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.EntityType.resolve(EntityType.java:412)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1030)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:987)
at org.hibernate.loader.Loader.doQuery(Loader.java:896)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:298)
at org.hibernate.loader.Loader.doList(Loader.java:2455)
at org.hibernate.loader.Loader.doList(Loader.java:2440)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2316)
at org.hibernate.loader.Loader.list(Loader.java:2311)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:414)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:364)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1192)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:116)
... 29 more
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@76e6d130
at sun.reflect.GeneratedMethodAccessor437.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:65)
... 59 more
The entity
import com.example.GUID
@Entity
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Table(name = "EQUIPMENT")
public class Equipment implements Serializable {
private GUID guid;
@Column(name = "GUID")
@Type(type = "com.example.PersistentGUID")
public GUID getGuid() {
return guid;
}
...
}
Oplossing
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow