読者です 読者をやめる 読者になる 読者になる

Quitada ブログ HAX

Hatena Blog でも Quitada ブログ

How to install GemFire HTTP session module on JBoss AS 7

According to the following document for GemFire HTTP session module, we can install the module on JBoss AS 7.

Installing the HTTP Module for AppServers 

But, regarding where to locate required jar files, it says "Consult application server's documentation" for JBoss AS 7 although just simply indicates actual location such as "<jboss install dir>/lib" for JBoss AS 5 or "<jboss install dir>/common/lib" for JBoss AS 6.

The main reason is that this kind of shared directory for common libraries has been discontinued since JBoss AS 7 in the part of avoiding "Jar Hell" based on introducing module system inspired by JSR294

I'm not so interested in module system but I tried to locate required jar files for GemFire HTTP session module on JBoss AS7 with using moudle system. Yeah, it works but I don't like it because it's slightly complex to configure. To make it easier to configure GemFire HTTP session module wiht JBoss AS 7 (or WildFly maybe), it's better to deploy your application and GemFire HTTP session module based on ear file with locating required jar files into lib directory of its ear.

Follow the following steps to locate and refer required jar files for GemFire HTTP sesseion moudle on JBoss AS 7.

  1. Determine the module name for GemFire session module. Any names could be O.K. but it tends to be based on package name of actual classes in the library. In this article, suppose that it's "io.pivotal.gemfire.session".
  2. Cretate a module folder for locatirng each libraries, module descriptor and so on, based on the module name. In this article, it's "io.pivotal.gemfire.session". So, please create the module folder like the following. 
    $ cd /path/to/JBossA7_install_dir/modules
    $ mkdir -p io/pivotal/gemfire/session/main
  3. Copy the required jar files for GemFire http session module (metioned here) to the module folder which was creted at the step 2 like the following in this case.
    $ cd /path/to/JBossA7_install_dir/modules/io/pivotal/gemfire/session/main
    $ cp /path/to/jar_files/gemfire-modules-<version>.jar
       :
  4. Change directory to the module folder created at the step 2 and create a module discriptor.

    $ cd /path/to/JBossA7_install_dir/modules/io/pivotal/gemfire/session/main
    $ vi module.xml

    The actual content of module.xml is below.

    <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="io.pivotal.gemfire.session">
        <properties>
        </properties>
        <resources>
          <resource-root path="antlr.jar"/>
          <resource-root path="gemfire.jar"/>
          <resource-root path="gemfire-modules-8.2.0.jar"/>
          <resource-root path="gemfire-modules-session-8.2.0.jar"/>
          <resource-root path="log4j-api-2.1.jar"/>
          <resource-root path="log4j-core-2.1.jar"/>
          <resource-root path="servlet-api-2.5.jar"/>
          <resource-root path="slf4j-api-1.7.7.jar"/>
          <resource-root path="slf4j-jdk14-1.7.7.jar"/>
          <resource-root path="spring-core-3.2.13.RELEASE.jar"/>
          <resource-root path="spring-shell-1.0.0.RELEASE.jar"/>
        </resources>
        <dependencies>
          <module name="javax.servlet.api"/>
          <module name="javax.api"/>
          <module name="javax.transaction.api"/>
        </dependencies>
    </module>

    First of all, you have to specify the module name at name attribute at module element. Second, you have to list the required jar file name at path attribute at resource-root elements as the child element of resouces element. At last, you have to set dependencies to load related module if you see ClassNotFoundException when loding this module. In my case, I need three modules to be set as dependencies.

  5. Additionally, you have to put jboss-deployment-structure.xml file under WEB-INF folder of your target war file to load the above module. The actual file content is like the following.

    <?xml version="1.0" encoding="UTF-8"?>
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
        <deployment>
          <dependencies>
            <module name="io.pivotal.gemfire.session" />
          </dependencies>
        </deployment>
    </jboss-deployment-structure>

    Basicaly, all you have to do is to specify the module name created for GemFire session module at name attribute of module element as the child element of dependencies element.  

Anyhow, does it work in your environment? Again, I don't like those module configuration, though...