简体   繁体   中英

Exclude jar from jboss AS 6 class loading

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM