3 Replies Latest reply on Feb 17, 2014 7:19 AM by usrcommunity

    Class Loading in Deployments in JBoss as 7

    usrcommunity

       

      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 Precedenceis 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