'How to force jboss to load classes from jars in webapp's lib
I am trying to deploy my web application on jboss-6.0.0Final
, which is currently deployed on apache tomcat
.
I have two jars one that contains same package which is org.apache.axis
. I am putting one jar in <Jboss-home>/server/default/lib
& another jar in <my-app-war>WEB-INF/lib
.
It is required to put both jars in the class path. No way to remove one of the jar. So I need to keep both jars. & It is giving me following error
java.lang.ClassCastException: org.apache.axis.attachments.AttachmentsImpl cannot be cast to org.apache.axis.attachments.Attachments
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.Call.invoke(Call.java:1828)
I think it is due to conflict of same classes in two different jars.
Now, I want to know the way by which I can force jboss to load classes of this particular package from axis.jar exist in /WEB-INF/lib.
How can I do that?
Solution 1:[1]
This helped me:
http://www.mastertheboss.com/jboss-configuration/solving-jboss-5-classloading-issues
Explode your war,
In your Exploded WAR web-inf directory add this xml file: jboss-classloading.xml
with content:
(domain is your war name)
<classloading xmlns="urn:jboss:classloading:1.0"
name="mywar.war"
domain="mywar_domain" <!-- (domain is your war name) -->
parent-domain="Ignored"
export-all="NON_EMPTY"
import-all="true">
</classloading>
Solution 2:[2]
I'll share quite simple and straight forward process which I had followed when I came across same situation.
1> Create a jboss-web.xml file.
<class-loading java2classloadingcompliance="false">
<loader-repository>
com.rts:archive=DTH_PROD.war
<loader-repository-config>
java2ParentDelegation=false
</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
Points:,
- Begin the xml with tag which is not visible in the code I'm posting Check 3rd line of above code,
- com.rts - This is your package name.
- DTH_PROD.war - Name of bundle you wish to keep
2> Now place this xml file into WEB-INF directory of your project and voilla!!
Further more you may wish to refer this article for detailed info. Also comment below if you face any difficulty solving this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | JavaSheriff |
Solution 2 | Pratik Ambani |