[
https://issues.jboss.org/browse/WFLY-6596?page=com.atlassian.jira.plugin....
]
Steve Ebersole commented on WFLY-6596:
--------------------------------------
That would indicate to me that you are using the same "cache region" for storing
both Country and Member data. Are you doing that explicitly (in annotations or XML,
etc)?
For illustration, when you have a {{Country#9}} and a {{Member#9}} both of those get
stored into their respective cache region using a "cache key". What I think is
happening is that in your case both {{Country#9}} and a {{Member#9}} get stored into the
same "Map" using the key 9... they collide. So if you put {{Country#9}} into
the cache and then try to find {{Member#9}} you'd get back the {{Country#9}} entry.
That would jive with a recent performance enhancement that changed the structure of this
"cache key". We used to essentially use a tuple of {{rootEntityName,id}}. The
recent change was performance related, and changed that to instead use just the {{id}}.
But obviously we need to be correct, then performant.
If my hunch is correct you could work around this by using distinct regions for your
entities.
You could also work around it by controlling the factory responsible for creating those
"cache keys". Unfortunately that is a l lot of work (too much) atm.
I created [
HHH-11083|https://hibernate.atlassian.net/browse/HHH-11083] to fix the bug in
Hibernate.
WrongClassException when using infinispan as remote-store for
hibernate entity cache
------------------------------------------------------------------------------------
Key: WFLY-6596
URL:
https://issues.jboss.org/browse/WFLY-6596
Project: WildFly
Issue Type: Bug
Components: JPA / Hibernate
Affects Versions: 10.0.0.Final, 10.1.0.Final
Environment: Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_45\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64",
family: "dos"
Infifnspan 8.1.2 or 8.2.0
Reporter: Gunther v. Wolffersdorff
Assignee: Scott Marlow
Labels: inifinispan-commons, org.hibernate.WrongClassException,
remote-store
Attachments: clustered.sample.xml, infinispan.zip, sample-10.1.0.Final-2.zip,
sample-10.1.0.Final.zip, sample.zip, standalone.sample.ha-10.1.0.Final.xml,
standalone.sample.ha.xml
Starting an application and then requesting a list of cachable JPA entitties ( configured
cachable using a hibernate entity invalidation-cache with a remote-server as remote-store
) causes:
{code}
13:00:52,541 MESZ ERROR [io.undertow.request] (default task-1) UT005023: Exception
handling request to /sample-web/rest/members/listAll:
org.jboss.resteasy.spi.UnhandledException: javax.persistence.PersistenceException:
org.hibernate.WrongClassException: Object [id=2] was not of the specified subclass
[de.alvara.ticket.sample.model.Country] : loaded object was of wrong class class
de.alvara.ticket.sample.model.Member
at
org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:77)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:220)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:175)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:418)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
[jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
at
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
[undertow-servlet-1.4.0.Final.jar:1.4.0.Final]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
[undertow-core-1.4.0.Final.jar:1.4.0.Final]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[rt.jar:1.8.0_66]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[rt.jar:1.8.0_66]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_66]
Caused by: javax.persistence.PersistenceException: org.hibernate.WrongClassException:
Object [id=2] was not of the specified subclass [de.alvara.ticket.sample.model.Country] :
loaded object was of wrong class class de.alvara.ticket.sample.model.Member
at
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
[hibernate-entitymanager-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
[hibernate-entitymanager-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:492)
[hibernate-entitymanager-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:50)
[hibernate-entitymanager-5.0.10.Final.jar:5.0.10.Final]
at
org.jboss.as.jpa.container.TypedQueryNonTxInvocationDetacher.getResultList(TypedQueryNonTxInvocationDetacher.java:58)
[wildfly-jpa-10.1.0.Final.jar:10.1.0.Final]
at
de.alvara.ticket.sample.data.MemberRepository.findAllOrderedByName(MemberRepository.java:58)
[sample-ejb.jar:]
at
de.alvara.ticket.sample.data.MemberRepository$Proxy$_$$_WeldClientProxy.findAllOrderedByName(Unknown
Source) [sample-ejb.jar:]
at
de.alvara.ticket.sample.rest.MemberResourceRESTService.listAllMembers(MemberResourceRESTService.java:75)
[classes:]
at
de.alvara.ticket.sample.rest.MemberResourceRESTService$Proxy$_$$_WeldClientProxy.listAllMembers(Unknown
Source) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_66]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[rt.jar:1.8.0_66]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.8.0_66]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_66]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)
[resteasy-jaxrs-3.0.19.Final.jar:3.0.19.Final]
... 43 more
Caused by: org.hibernate.WrongClassException: Object [id=2] was not of the specified
subclass [de.alvara.ticket.sample.model.Country] : loaded object was of wrong class class
de.alvara.ticket.sample.model.Member
at
org.hibernate.event.internal.DefaultLoadEventListener.processCachedEntry(DefaultLoadEventListener.java:631)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.event.internal.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:602)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:462)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1129)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1022)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:632)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.type.EntityType.resolve(EntityType.java:424)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:154)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:128)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1133)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.Loader.processResultSet(Loader.java:992)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:930)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2617)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2600)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.Loader.list(Loader.java:2424)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at
org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1326)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
[hibernate-core-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606)
[hibernate-entitymanager-5.0.10.Final.jar:5.0.10.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483)
[hibernate-entitymanager-5.0.10.Final.jar:5.0.10.Final]
... 58 more
{code}
Entity cache is configured like this:
{code:xml}
...
<invalidation-cache name="entity" mode="SYNC">
<eviction strategy="LRU"
max-entries="1000"/>
<expiration lifespan="45000"
max-idle="30000"/>
<remote-store cache="hibernateDistributed"
socket-timeout="60000" tcp-no-delay="true"
remote-servers="local-cache-server" fetch-state="false"
passivation="false" preload="false" purge="true"
shared="true"/>
</invalidation-cache>
...
<outbound-socket-binding name="local-cache-server">
<remote-destination host="${jboss.bind.address:127.0.0.1}"
port="11322"/>
</outbound-socket-binding>
...
{code}
see standalone.sample.ha-10.1.0.Final.xml .
*This constellation works fine using Wildfly 8.2.0 and Infinispan 7.2.5 .*
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)