What would help us to resolve your problem is to post the details of your application structure.

Also if would help if you could set a ClassCastException breakpoint in your IDE, and report the two different class loaders that are causing the problem(i.e. the expected class loader and the actual class loader).

I saw that XMLSignatureFactory.java:202 doesn't correspond to correct line to XMLSignatureFactory contained into running JVM rt.jar. Seems to me that jboss runtime use the one contained into module org\apache\santuario\xmlsec. This module contains xmlsec-1.5.1.jar: is this a stable version?