2
votes

Reading the documentation of redhat (https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Development_Guide/chap-Class_Loading_and_Modules.html) I found that the application server classloader has a priority list when loading classes that are used to avoid any conflict between loaded classes, The order is as below

  • Implicit dependencies. These are the dependencies that are added automatically by JBoss Enterprise Application Platform 6, such as the JAVA EE APIs. These dependencies have the highest class loader precedence because they contain common functionality and APIs that are supplied by JBoss Enterprise Application Platform 6. Refer to Section 3.7.1, “Implicit Module Dependencies” for complete details about each implicit dependency.
  • Explicit dependencies. These are dependencies that are manually added in the application configuration. This can be done using the application's MANIFEST.MF file or the new optional JBoss deployment descriptor jboss-deployment-structure.xml file. Refer to Section 3.2, “Add an Explicit Module Dependency to a Deployment” to learn how to add explicit dependencies.
  • Local resources. Class files packaged up inside the deployment itself, e.g. from the WEB-INF/classes or WEB-INF/lib directories of a WAR file.
  • Inter-deployment dependencies. These are dependencies on other deployments in a EAR deployment. This can include classes in the lib directory of the EAR or classes defined in other EJB jars.

I tried to test this order by using a JSF webapp (rich faces) in my EAR archive My ear is as below :

sample.ear

--- sport.war

--- mysql.jar

--- lib

  • Usescase 1 : I added the JSF jars under the webapp (sport.war/WEB-INF/lib): [jsf-api-2.1.14.jar/jsf-impl-2.1.14.jar/portletbridge-api-3.1.2.Final.jar/portletbridge-impl-3.1.2.Final.jar], the jboss server started well and I don't have any exception
  • Usescase2: I added the JSF jars under sample.ear/lib ==> When I start the jboss server I get an exception (it sounds that the application server loaded the module JSF provided by jboss Implicit dependencies instead of the one in my sample.ear/lib)

I can't understand why in the 1srt usescase the Class Loading Precedence is not respected while in the 2sd usescase the Class Loading Precedence is respected?

Could you please clarify me this point

ENV

  1. JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8)
  2. JDK 6
1

1 Answers

0
votes

Without seeing the exact deployment exception that you got it is difficult to diagnose the issue.

  • In the first scenario the packaged libraries are loaded in the same class loader as your application.

  • In the second scenario the packaged libraries are loaded in a separate module and class loader.

The above means that , The deployment issue you were having fo not have to be related to Class Loading Precedence they could also be related to Class Loading Isolation.

Also Jboss and EAP already come with a prepackaged implementation of JSF, and you might be experiencing collisions due to version mismatch

If you were looking to replace the default JSF implementation on JBoss the better option to do so would have been to put the new JSF implementation in a static module, just like the default one , and have Jboss load it on demand.