Exclude jar from jboss AS 6 class loading

1.6k views Asked by At

I have a war that uses the errai-bus, which depends on guava 14.0.1. I'm deploying the app with Jboss, but when I do, Jboss is using its weld version of guava, which is guava r6 (very old). This causes horrible class loading issues and the errai-bus completely fails to work.

Even when I declare guava 14.0.1 as a top-level dependency in my pom, it still uses guava r6. How can I stop Jboss from loading the wrong guava version for my war?

I've tried to look up info about how to do this with the class loader files in Jboss AS 6, but I can't seem to find any documentation.

1

There are 1 answers

1
Federico Sierra On

You can try 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, put the war's classloader in the mywar_domain which is shared with all other applications that don't define their own domain. 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 you get when you 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.

See also:

Anyway JBoss AS 6 is out of date, and have a lot of de bugs unresolved. You would have to see the possibility of using a newer version (Wildfly or JBoss EAP 6).