We have a lot of cases where customers take war files that run fine in Tomcat or other applications servers and when they deploy to JBoss they get various classloading issues. They do not understand why it works in Tomcat and not JBoss since JBossWeb is basically using Tomcat underneath. The reason is many of them have 3rd party apps which are war files and include various jars some of which are api jars such as xml-apis.jar and servlet-api.jar.
According to Tomcat documentation it will ignore servlet-api.jar if it is packaged in the war and it also seems to ignore other classes which already exist in the JVM as the only way to override them would be to use the endorsed directory option.
I found that adding packages to the filteredPackages makes JBoss behave more like Tomcat, where it will ignore classes which are in the JVM.
Is there a reason we are not already filtering JVM packages? Because if a user packages any of the classes in the JVM and they get used they will have ClassCast errors. Below are the ones I had to add, but it seems we would list all packages that the JVM contains.
deployers/jbossweb.deployer/META-INF/war-deployers-jboss-beans.xml
<property
name="filteredPackages">javax.servlet,org.apache.commons.logging,javax.xml,org.w3c.dom,org.xml.sax</property>