0

I've ran into a problem using Spring's and ManagedExecutorService in Jboss. When marshalling objects in a runnable I get a ClassCastException saying class can't be cast to the same class, seems like the classloader sticks around when application is redeployed and new tasks are submitted.

MattD
  • 46
  • 2
  • Possible duplicate of [ClassCastException when casting to the same class](https://stackoverflow.com/questions/826319/classcastexception-when-casting-to-the-same-class) – ETO Nov 16 '18 at 06:55

1 Answers1

0

It's difficult to say exactly what is causing your error without seeing code and the full error.

However here is perhaps a relevant thread : ClassCastException when casting to the same class

As said in this thread, maybe you have loaded the class with one classloader then tried to cast it to the same class loaded by another classloader?

John Kim
  • 1,081
  • 10
  • 26
  • I suspected that this is what is happening. In this case the code is simply marshalling a pojo from xml or json. The code has this problem after the application is redeployed and a new task is submitted to the managed executor service. It seems JBoss is still using the old classloader when running the new task. – MattD Nov 16 '18 at 06:46
  • Perhaps you should look in the classloading configuration for JBoss and see if the issue is there. – John Kim Nov 16 '18 at 06:58
  • When using java.util.concurrent.ThreadPoolExecutor the issue doesn't appear. – MattD Nov 18 '18 at 01:36