]
worldline_ge_dev worldline_ge_dev commented on ISPN-10138:
----------------------------------------------------------
thanks for the explanation, could be the reason. Unfortunately, it is too complex to drill
this down to a simple example application and we don't use CompletableFuture anymore,
so currently the problem seems solved for us. It is then more a JBoss classloading
problem? It seems to me very strange that classloading behaviour depends on whether I
start two applications simultaneously or one after the other. Even when starting
simultaneously the error could maybe occur at random
JMS ClassCastException
----------------------
Key: ISPN-10138
URL:
https://issues.jboss.org/browse/ISPN-10138
Project: Infinispan
Issue Type: Bug
Components: Listeners
Affects Versions: 9.4.4.Final
Environment: JBoss 6.4.10.GA
Infinispan 9.4.4.FINAL
hornetq 2.3.25.FINAL
jdk 1.8.0_92
Reporter: worldline_ge_dev worldline_ge_dev
Priority: Minor
We have a malfunction that we think is a bug but are not sure whether it is a JBoss,
HornetQ or Infinspan issue. Here is the situation:
Two war applications on one JBoss, one sends data into a JMS queue, the other consumes
them. On startup, each application registers in a replicated Infinispan cache.
Infinispan subsystem is excluded in jboss-deployment-structure.xml and libs are in the
lib folder of the applications. When we start JBoss and both applications are deployed
simultaneously,
all is okay. When first the consuming app is deployed and then the sending app we observe
following error in last line of the following code in MessageListener:
{code:java}
public void process(Message inMessage) {
DistributionMetadata metadata = null;
log.info("DistributionMetadata.class.getClassLoader().toString(): " +
DistributionMetadata.class.getClassLoader().toString());
try {
Object obj = ((ObjectMessage) inMessage).getObject();
log.info("obj.getClass().getClassLoader().toString(): " +
obj.getClass().getClassLoader().toString());
metadata = (DistributionMetadata) obj;
{code}
INFO 12:01:41,805 (Thread-9 (HornetQ-client-global-threads-1054694434))
(JmsConsumer.java:process:214) -
DistributionMetadata.class.getClassLoader().toString(): ModuleClassLoader for Module
"deployment.msp.war:main" from Service Module Loader
obj.getClass().getClassLoader().toString(): ModuleClassLoader for Module
"deployment.bvn-idx-routing.war:main" from Service Module Loader
ERROR 12:01:41,805 (Thread-9 (HornetQ-client-global-threads-1054694434))
(JmsConsumer.java:process:244) -FAILED:
com.equensworldline.jms.entities.DistributionMetadata cannot be cast to
com.equensworldline.jms.entities.DistributionMetadata: java.lang.ClassCastException:
com.equensworldline.jms.entities.DistributionMetadata cannot be cast to
com.equensworldline.jms.entities.DistributionMetadata
at com.equensworldline.jms.api.external.JmsConsumer.process(JmsConsumer.java:217)
at
com.equensworldline.correlationidmgmt.jee.CorrelationIDMessageListener.onMessage(CorrelationIDMessageListener.java:32)
at
org.hornetq.jms.client.JMSMessageListenerWrapper.onMessage(JMSMessageListenerWrapper.java:100)
at
org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1123)
at
org.hornetq.core.client.impl.ClientConsumerImpl.access$500(ClientConsumerImpl.java:57)
at
org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1258)
at
org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:105)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
You see the DistributionMetadata class is loaded by two different classloaders which
causes this error.
The remedy we found is very strange and has on first sight nothing to do with the
failure:
We have registered an Infinispan cachelistener and within the @CacheEntryCreated event we
start a JMS listener and access the cache. Because we observed
org.infinispan.util.concurrent.TimeoutException
we make this asynchronously following the advice in
[
https://developer.jboss.org/thread/268919|https://developer.jboss.org/thr...].
{code:java}
CompletableFuture.runAsync(() -> regService.startListener(event.getValue()));
{code}
When we change back to a synchronous call, everything works and the ClassCastException
does not occur. It seems, either Infinispan, HornetQ or JBoss does something queer with
the classloaders in the described situation