Saturday, March 12, 2016

Create Common Module in JBoss AS7x/EAP6x

Hello Guys.

Hope you are doing great in your environment and enjoying the beautiful life.

After very long time I'm writing blogs. Today's I will explain the problem which I've faced during Tuxedo system integration with Jboss EAP server. `

During the integration I faced many strange exception and errors. I applied different approach but seemed no luck. Than among all try I thought that some common jars which were being used by my apps might be causing the issue. Sorry I didn't brief about project's architecture. So, let me explain first. I've to do integration with Tuxedo System via JBoss EAP server. I've used TuxedoAdapter.rar which is provided by Oracle as a JCA. This adapter will communicate with Tuxedo system and my web apps needed to communicate with this adapter.

I've started thinking to create a common module in which the commonly used jars files were available and by surprise this approach worked for me. Let me shared the basic steps which I took to do this.

Step 1: I've created one module.xml in which I've added the jar which are going to used commonly.

<module xmlns="urn:jboss:module:1.1" name="common-jars">
<!--<properties>
    <property name="jboss.api" value="private"/>
</properties>-->

<resources>
    <resource-root path="com.bea.core.i18n_1.4.0.0.jar"/>
    <resource-root path="com.bea.core.jatmi_1.3.1.0.jar"/>
    <resource-root path="com.oracle.tuxedo.adapter_1.1.0.0.jar"/>
    <!-- Insert resources here -->
</resources>

<dependencies>
    <module name="javaee.api"/>
    <module name="javax.api"/>
</dependencies>
</module>
Step 2: Created a directory as following common\jars\main in $EAP-HOME\modules\system\layers\base

Step 3: 
Added module.xml and the jar files in $EAP-HOME\modules\system\layers\base\common\jars\main

Step 4: Modified $EAP-HOME\standalone\configuration\standalone.xml as per below,


<subsystem xmlns="urn:jboss:domain:ee:1.2">
     <global-modules>
          <module name="common.jars"/>
     </global-modules>
     <spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
     <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
     <annotation-property-replacement>false</annotation-property-replacement>
</subsystem>
Note: <module> element has an optional attribute with name @slot where you can specify the directory to look into your common jar files. If you don't specify than default value is main

Step 5:Removed the common jars from TuxedoAdapter.rar and my web app war file.

Step 6: Restarted the JBoss AS or EAP server
That's it. It's worked for me. This article is more about how to create the shared/common module which being used by various deployed apps in EAP or server. Sometime you have case like more than one apps are using some common third party libraries. This time it is better to use common/shared module rather than using duplicate libraries in the apps which adds extra overhead on Application Server.

Hope this will help. Share your valuable inputs to make this article more informative among all of tech-guys.

Kindly add your comment if you have some suggestions. I will see those feedback and if required I will add in this article.

Cheers,
Ashish Mishra

No comments:

Post a Comment