Jboss Module Slot

JBoss has a module “sun.jdk” which is used to load the jdk classes. For some reason not all classes are referenced. In order to allow for the sun or com related jdk packages which are not getting loaded we need to register them under the “sun.jdk” module. JBoss Enterprise Application Platform; JBEAP-12467 (7.1.0) Module naming does does not support slots. Jboss As 7 Module Slot, free slots monopoly no download, seminole casino, sz casino. Visit casino 150.

Hi,
AS 7 does classloading right. It uses JBoss Modules to provide true application isolation, hiding server implementation classes from the application and only loading the classes your application needs. Modules, packaged as collections of classes, are peers that remain isolated unless explicitly defined as a dependency of another module. Visibility rules have sensible defaults, yet can be customized.

Modular classloading is one of the greatest and amazing feature of JBossAS7, but some application server admins are not much aware of this new feature. So here we are going to see a practicle demo of creating a module on JBoss AS7.1.1.Final.

Few Points Which we are going to discuss here:

Point-1). How to create our own custom modules?

Point-2). What is the need of “module.xml” and where to place it?

Point-3). What is “slot” and Why and When to define “slot” in our “module.xml” file?

Point-4). How to reference a module inside our webapplication for classloading purpose?

Point-5). How and why to use the “META-INF/jboss-deployment-structure.xml” or “WEB-INF/jboss-deployment-structure.xml” file?

***NOTE*** This demo is also available in Github:
https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/JBossAS7_module_slot_Demo

Developing a Custom Module:

Step-1). Create a directory somewhere in your file system where we will develop our own custom Module with some different versions of class files. Suppose the directory is “/home/userone/CustomModuleTest”

Step-2). Now create a directories structure as “aaa/bbb/1.0” and “aa/bbb/main” inside the directory “/home/userone/CustomModuleTest”.

Step-3). Now write a class with name “Test.java” inside “/home/userone/CustomModuleTest/aaa/bbb/1.0” as following:

Step-4). Similarly write a “Test.java” program as following inside the directory “/home/userone/CustomModuleTest/aaa/bbb/main” :

***NOTE***: The class “aaa.bbb.Test” is same as mentioned in Step3 and Step4 but there is a slight different in the implementation of these classes like the Version of the class is 1.0 and 1.2 as you can see in the static block of the code. This is just to demonstrate that how we can load any version of the same class inside our application with the help of “slot” concept of JBoss Modules.

Step-5). Now we will need to write a file with name “module.xml” inside the directory “/home/userone/CustomModuleTest/aaa/bbb/1.0” as following:

Step-6). Now we will need to write another file with name “module.xml” inside the directory “/home/userone/CustomModuleTest/aaa/bbb/main” as following:

***NOTE*** If we have the same Jars of different versions defined as part of a module then the Jar which is present inside the “main” directory of the module will be utilized by default until the application uses “META-INF/jboss-deployment-structure.xml” or “WEB-INF/jboss-deployment-structure.xml” to mention which “slot” (version) it want to use.

Step-7). Now it’s turn to compile the Test.java class. So open a shell prompt and then make sure that your PATH variable is set properly to point to the JDK bin directory as following:

Step-8). In the abobe shell prompt now move inside the directory “/home/userone/CustomModuleTest/aaa/bbb/main” to compile the Test.java program and to create a Test1.2.jar file as following:

Step-9). Similarly we wiill compile the Test.java present inside the “/home/userone/CustomModuleTest/aaa/bbb/1.0”. So in the abobe shell prompt now move inside the directory “/home/userone/CustomModuleTest/aaa/bbb/1.0” to compile the Test.java program and to create a Test1.0.jar file as following:

Step-10). Now just copy and paste your custom module directory “aaa” directory placed inside the “/home/userone/CustomModuleTest” to destination directory “/home/userone/jboss-as-7.1.1.Final/modules”

Step-11). Now restart your JBossAS7 server as following:

Testing the Custom Module and it’s slot:

Now we are going to develop a simple web application which will demonstrate how we can load the module, which has name “aaa.bbb” inside our application. And how to load various versions of the same class “aaa.bbb.Test” with the help of “slot” using “WEB-INF/jboss-deployment-structure.xml”

Step-12). Just create a WebApplication directory “TestCustomModule.war” somewhere in your file system like inside “/home/userone/CustomModuleTest”

Step-14). Write the following kind of simple “index.jsp” page inside our Web Application directory “/home/userone/CustomModuleTest/TestCustomModule.war”

Step-15). Create another directory “WEB-INF” as “/home/userone/CustomModuleTest/TestCustomModule.war/WEB-INF” and then palce the following kind of “web.xml” file inside it :

Step-16). Create another file with name “jboss-deployment-structure.xml” inside “/home/userone/CustomModuleTest/TestCustomModule.war/WEB-INF”, Now with the help of this file we will specify which version of the “aaa.bbb.Test ” class we want to use in our application.

Step-17). Copy and paste the “TestCustomModule.war” directory inside your JBossAS7 standalone deployment directory “/home/userone/jboss-as-7.1.1.Final/standalone/deployments”

Step-18). Now write a file with name “TestCustomModule.war.dodeploy” inside the JBoss deployment directory “/home/userone/jboss-as-7.1.1.Final/standalone/deployments” to tell JBoss AS7 to deploy our application. (NOTE: as our application is Exploaded directory so we need to create this file otherwise war/jar/ear “FILES” are automatically deployed without creating *.dodeploy file.)

Step-19). Access the application as “http://localhost:8080/TestCustomModule/index.jsp” to see if your JSP file is able to access the “aaa.bbb.Test” class or not? In the JBoss Console (command prompt output/STDOUT) you will see following kind of output.

Further Testing & Verification :

Jboss Module Slots

Step-20). At the time of application deployment based on the version of module which you mentioned in your “jboss-deployment-structure.xml”, If your module is loaded and deployed successfully then you will see a file with name “Test1.0.jar.index” or “Test1.2.jar.index” name inside the “/home/userone/jboss-as-7.1.1.Final/modules/aaa/bbb/1.0” or “/home/userone/jboss-as-7.1.1.Final/modules/aaa/bbb/main”

Step-21). Remove the “slot=1.0” attribute in your “” file as following then redeploy your WebApplication then see access the same index.jsp page ….. you will notice that now JBoss AS7 will load the 1.2 version of aaa.bbb.Text class as this is the default version.

Folllowing kind of output your will see now after redeployment of your application :

Jboss

Notice that this time a 1.2 version of aaa.bbb.Test class is loaded by JBoss.

.
.
Thanks 🙂
Middleware Magic Team

The file jboss-deployment-structure.xml can ne used to set application dependency against modules. The advantage of using this file (compared to the Manifest’s entry) is that you can define dependencies across top-level deployments and subdeployments.

An example of jboss-deployment-structure.xml

Here is an example which adds a deployed module to the application's classpath:

If we want a more restrictive policy, we can include the dependency just for the sub-module named myapp.war which is included in the EAR:

Module

The above examples are using deployment-based dependencies; you can however reference your modules installed in the modules folder as in the following example where we are referencing log4j libraries:

If you need to provide a fine-grained control over your dependencies, you can exclude/include some packages from your dependencies. Let’s take as an example the following application which is composed of these artifacts:

As it is, you don't need configuring the jboss-deployment-structure.xml to use the itext classes, which are picked up from the lib folder.

However, what if you want to select which packages to use of included itext library? That can be done by defining the itext library as a module and include a filter in it, which excludes for example the com/itextpdf/awt/geom package:

How to prevent your modules from being loaded using jboss-deployment-structure.xml

Here's for example how to prevent your application to use dom4j libraries and use the XOM (http://www.xom.nu/) object module which we have installed as module name 'org.xom':

As a footnote, please be aware that you can use the slot parameter in the module name in order to specify a dependency against a particular

release of a module. In the following example we want to replace the default (main) implementation of the com.mysql module with the one contained in the slot named 1.26.

Here’s the view of the com.mysql folder under your modules tree:

This is the corresponding configuration needed to use the slot 1.26 for your JDBC Driver:

Jboss Module Sloth

How to prevent a subsystem from being loaded

Jboss Module Slot Machine

Jboss module slots

Another feature of the jboss-deployment-structure.xml file is the ability to prevent the classloader to use a subsystem included in the application server. In the following example, we are excluding the resteasy subsystem that is used for consuming REST Messages:

Please note that if the exclude-subsystem is specified for the top-level archive, it will be inherited by sub deployments, unless the sub deployments specify their own (possibly empty) list.