move shared class into jar that is in static jboss module, not in deployment.
than add dependency to it in your deployment.
do that on both servers, this way class will be in same module on both servers so infinispan will be able to find it.
Is there any way to keep that class in the original war file?
For example, to keep this "static jboss module" inside this war file?
It's not important how ugly this way may be
For moving into external module, I think that our information security division just reject this way of deployment, because wildfly (and other system things) have to be sacred and untouchable.
We can slightly change standalone.xml, like modifying TCPPING section, but nothing more.
Eg, we have our own web service stack, serialization stack, etc inside the war file, and not using anything provided by wildfly, because we can't tune base platform as we like.
Why not bundle your WAR files and a JAR containing com.my.shared.classes.MyClass within an EAR?