[Download] | [Documentation Index] | [Release Note]
CARBON_HOME/repository/deployment/server/
AAR Services - CARBON_HOME/repository/deployment/server/axis2services
JAX-WS Services - CARBON_HOME/repository/deployment/server/servicejars
These services can load classes from 4 different locations. Numbers 1, 2, 3, 4 will
be used to refer the above 4 locations respectively.
Ex: If you've installed mediation features into WSO2 AppServer and you want to share the same library between a mediator and a AAR service.
Note: If your external dependency is already an OSGi bundle, you can directly copy that bundle into CARBON_HOME/repository/components/dropins folder and the behavior will be the same as above.
Ex: If you have a AAR service and a JAX-WS service which shares the same dependency, you can copy it into this location.
Ex: If you have two different AAR services which shares the same dependency, you can copy it into the axis2services/lib folder.
Ex: If your StudentMarks.aar service depends on foo.jar, embed the .jar file inside the AAR file as shown below.
StudentMarks.aar
- META-INF
- services.xml
- lib
- foo.jar
- org
- wso2
- sample
- Marks.class
Now let's have a look at how we can change the class loading behavior among the above mentioned locations.
WSO2 AppServer follows parent first class loading by default. You can see that by opening the CARBON_HOME/repository/conf/axis2.xml file and checking the following parameter.
<parameter name="EnableChildFirstClassLoading">false</parameter>
That means the priority reduces in the order 1 > 2 > 3 > 4 above. So when loading classes, highest priority is given to location 1 above and the least priority is give to location 4 above.
Ex: If you have two different versions of the same library in 1 and 3 above and your AAR service depends on that library, classes will be loaded from the library in location 1.
If you want to enable child first class loading, you can do that by opening the CARBON_HOME/repository/conf/axis2.xml file and setting the value of the following parameter to 'true'.
<parameter name="EnableChildFirstClassLoading">true</parameter>
That means the priority reduces in the order 4 > 3 > 2 > 1 above. So when loading classes, highest priority is given to location 4 above and the least priority is give to location 1 above.
Ex: If you have two different versions of the same library in 1 and 3 above and your AAR service depends on that library, classes will be loaded from the library in location 3.
If you want to enable child first class loading only for a particular AAR service while the overall server behavior remains parent first, you can add the above parameter into the META-INF/services.xml file of the AAR file.
<parameter name="EnableChildFirstClassLoading">true</parameter>
Ex: If you have two different versions of the same library in location 1 and 4 above, adn your service depends on that library, classes will be loaded from the library in location 4.
Note: You can only control the behavior of location 4 using this method. Therefore, use this method only when you've embedded your libraries inside your service archive.
Web Applications deployed in WSO2 AppServer can load classes from two locations.
Important: You have to be careful when copying libraries into above location 1 as it can change the behavior of the server if a conflict occurs with the existing libraries. Therefore, it is recommended to use location 2 whenever possible.
Class loading pattern for Web Applications is always child first and you can't change it. Therefore location 2 above is always given the highest priority when the same library exists in both locations.