Hi,

Jay SenSharma

Jay SenSharma

In response to comment posted regarding tunning of EJB3 app:   http://middlewaremagic.com/weblogic/?p=1696#comment-1356

Here is a Simple Demonstration of Changing the Tunable Parameters of an EJB3.0 application using “Plan.xml”. As we have many annotations available as part of EJB3.0 Specifications But we dont have the Annotations available for many Tunable parameters like “max-beans-in-free-pool”, “initial-beans-in-free-pool”…etc. If we want to change/add these values for our EJB3.0/EJB2.x Application then we have have to change provide our own “weblogic-ejb-jar.xml” file.

But In Most of the production scenarios The WebLogic Administrator doesnt have priviledge to change any thing inside the EJB jar module. So in that case A WebLogic AdminiStartor can use the “Plan.xml” file to change these Tunable Parameters Settings…

Step1). Create a Directory somewhere in your file system.
Example: C:EJB3_Plan_XML_Demo

Step2). Create a Directory “EJB3App” inside Directory “C:EJB3_Plan_XML_Demo”

Step3). Provide the EJB3 Business Interface “CalculatorRemote.java” inside “C:EJB3_Plan_XML_DemoEJB3App”

package calculator;
import javax.ejb.*;
@Remote
public interface CalculatorRemote
{
public int add(int x,int y);
public int sub(int x,int y);
public int mult(int x,int y);
public int div(int x,int y);
}

Step4). Provide the EJB3 Stateless Bean Implementation class “CalculatorBean.java” inside “C:EJB3_Plan_XML_DemoEJB3App”

package calculator;
import javax.ejb.*;
@Stateless
public class CalculatorBean implements CalculatorRemote
{
public int add(int x,int y)
{
return (x+y);
}
public int sub(int x,int y)
{
return(x-y);
}
public int mult(int x,int y)
{
return (x*y);
}
public int div(int x,int y)
{
return (x/y);
}
}

Step5). Now Create a directory “META-INF” inside “C:EJB3_Plan_XML_DemoEJB3App” and then provide an Empty “weblogic-ejb-jar.xml” file as following:

<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd">
</weblogic-ejb-jar>

NOTE: Step5 is the Most important Step because if we want to override setting of any descriptor then at least that file must exist inside our application….doesn’t matter if it is Empty or having some contents inside it.

Step6). Now a command prompt and the run the “setWLSEnv.cmd” and then Compile the above two ejb stuffs.

Compiling_EJB3_App

Compiling_EJB3_Ap

Step7). Write the “build.xml” file to deploy your Application…inside “C:EJB3_Plan_XML_Demo” like following:

<project name="webservices-hello_world" default="deploy">
<!-- set global properties for this build -->
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="weblogic" />
<property name="wls.hostname" value="localhost" />
<property name="wls.port" value="7001? />
<property name="wls.server.name" value="AdminServer" />

<target name="deploy">
<wldeploy action="deploy" name="EJB3App" source="EJB3App"
user="${wls.username}" password="${wls.password}" verbose="true"
adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" />
</target>

<target name="undeploy">
<wldeploy action="undeploy" name="EJB3App" failonerror="false"
user="${wls.username}" password="${wls.password}" verbose="true"
adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" />
</target>

</project>

Step8). Now open a Command prompt and then run “setWLSEnv.cmd” then run the above ant “build.xml” file to deploy your application:

Deploying_EJB3_App_using_Ant

Deploying_EJB3_App_Using_Ant

Step9). Now Login to Admin Consoel to see how many initial beans have been created for our EJB3App.

Step10). Now Provide the “plan.xml” file inside “C:EJB3_Plan_XML_Demo” location as following to change the “initial-bean-in-free-pool” setting for our EJB3App…

<?xml version=’1.0' encoding=’UTF-8'?>
<deployment-plan xmlns="http://www.bea.com/ns/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/deployment-plan http://www.bea.com/ns/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
<application-name>EJB3App</application-name>

<variable-definition>
<variable>
<name>initialPoolVariable</name>
<value>15</value>
</variable>
</variable-definition>

<module-override>
<module-name>EJB3App</module-name>
<module-type>ejb</module-type>
<module-descriptor external="true">
<root-element>weblogic-ejb-jar</root-element>
<uri>META-INF/weblogic-ejb-jar.xml</uri>
<variable-assignment>
<name>initialPoolVariable</name>
<xpath>/weblogic-ejb-jar/weblogic-enterprise-bean/[ejb-name="CalculatorBean"]/stateless-session-descriptor/pool/initial-beans-in-free-pool</xpath>
</variable-assignment>
</module-descriptor>
</module-override>

<config-root>C:EJB3_Plan_XML_Demo</config-root>
</deployment-plan>

Step11). provide the “build_with_plan.xml” file inside “C:EJB3_Plan_XML_Demo” to redepoy the application with the settings provided as part of our “plan.xml” file. Like following :

Redeploying_EJB_Using_Pla

Redeploying_EJB_Using_Pla

Step12). Now again Login to AdminConsole and then see the Monitoring Tab of your EJB3App … like following:

AfterRedeploying_UsingPlan

AfterRedeploying_UsingPlan

.

.

Thanks

Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.