Solving JBoss 5 classloading issues
- Published: 16 November 2009
The simplest way to fix this problem, is to remove the libraries under WEB-INF/lib that you have in your JBoss server installation ( server/xxx/lib for JBoss 4 , or common/lib for JBoss 5).
However it can be that you need a more recent (or earlier) release of your library so you want to keep your library in WEB-INF/lib.
In this article we have shown how to solve a few issues with Classloading with JBoss 4
18:10:45,353 INFO [TomcatDeployment] deploy, ctxPath=/mywar.war
18:10:45,462 ERROR [JBossContextConfig] XML error parsing: context.xml
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser
Now add the following jboss-classloading.xml to your WEB-INF folder:
<classloading xmlns="urn:jboss:classloading:1.0" name="mywar.war" domain="mywar_domain"> parent-domain="Ignored" export-all="NON_EMPTY" import-all="true"> </classloading>
In this case, we put the war's classloader in the "mywar_domain" which is shared with all other applications that don't define their own domain. We also choose to look at all other classes exported by other applications "import-all" and to expose all our classes to other classes "export-all".
What we get when we deploy this file, is that the Web application classloader will act as top-level Classloader so there will be no conflict with the same classes in the server's library.
The application structure with the jboss-classloading.xml turns to.