Sterling OMS Hot Deployment Weblogic Server
Sterling OMS Hot Deployment Weblogic Server : After our first post (Sterling OMS Writing First Java Program), one of our well-wisher shared about hot deployment. Yes Hot Deployment really useful to developers. In this post we are going to see how to setup hot development and save time.

Consider below simple scenario
- Customer wants to get organization details using given input XML (Can be in any format)
- Input XML coming into Service looks as shown below
<?xml version="1.0"?> <Enterprise EnterpriseCode="Matrix" />

- Create java file
package com.oms94.test;
import java.io.StringWriter;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import com.yantra.yfc.dom.YFCDocument;
import com.yantra.yfs.japi.YFSEnvironment;
public class MapEnterprise {
/**
* Input: <Enterprise EnterpriseCode="Matrix" />
* Expected Output : <Organization OrganizationCode="Matrix"/>
*
* @param env
* @param doc
* @return
*/
public Document map(YFSEnvironment env, Document doc) {
if(doc == null) {
return doc;
}
System.out.println("Input : " + getStringFromDocument(doc));
String enterpriseCode = doc.getDocumentElement().getAttribute("EnterpriseCode");
YFCDocument document = YFCDocument.createDocument("Organization");
document.getDocumentElement().setAttribute("OrganizationCode", enterpriseCode);
System.out.println("Output : " + getStringFromDocument(document.getDocument()));
return document.getDocument();
}
private String getStringFromDocument(Document doc)
{
try
{
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
return writer.toString();
}
catch(TransformerException ex) {
return null;
}
}
/**
* Used For testing only
* @param args
*/
public static void main(String[] args) {
MapEnterprise mapEnterprise = new MapEnterprise();
YFCDocument inputDocument = YFCDocument.createDocument("Enterprise");
inputDocument.getDocumentElement().setAttribute("EnterpriseCode", "Matrix");
mapEnterprise.map(null, inputDocument.getDocument());
}
}
- Final Result XML to call getOrganizationHierarchy API
<Organization OrganizationCode="Matrix" />
Configuration Change Required
- Create new service with name JavaEnterpriseMapTest and Service group name Custom

- Add extended API (From Component section) as shown below and class and method names

- Add Standard API (From Component section) as shown below

- Connect all the points

- Click Save
How to build custom code? (Only Once)
- Go Eclipse Right click on project name SterlingCustom94
- Select Export
- Under Java — Select Jar file
- Select Jar file location <Install Directory>\jar\customjar\1\SterlingCustom94.jar
- Run Command : deployer.cmd -t resourcejar
- Run Command : buildear.cmd -Dappserver=weblogic -Dwarfiles=smcfs,sbc -Dearfile=smcfs.ear -Dnowebservice=true -Ddevmode=true -Dnodocear=true -Dwls-10=true create-ear
- Run Command: del C:\deploy\smcfs.ear (Deleting old ear file)
- copy <Install Directory>\external_deployments\smcfs.ear C:\deploy
How to perform Hot Deployment?
- Extract From C:\deploy\smcfs.ear file into C:\deploy\smcfs.ear folder (One time)
- Extract From C:\deploy\smcfs.ear\smcfs.war file into C:\deploy\smcfs.ear\smcfs.war folder (One time)

- Go Eclipse Right click on project name SterlingCustom94 (Repeat below steps when code change made)
- Select Export
- Under Java — Select Jar file
- Select Jar file location C:\deploy\smcfs.ear\SterlingCustom94.jar
- Complete jar file creation
Weblogic Deployment
- Login to weblogic console http://localhost:7001/console
- Deployments link — Using Delete button remove the previous ear (if any)
- Click Install button
- Select directory C:\deploy and select smcfs.ear folder (Open Directory)
- Complete the deployment
- Make sure application deployed successfully and present in active status
Run the test?
Input

Output

Conclusion
Moving forward you can just make code change and build custom jar file using eclipse export option and just stop and start weblogic server or perform redeploy to test changes.
You are ready for testing.
Note: Deploy and redeploy can be done via command line. Let’s see how to perform auto build and deploy using command line in another post.
Happy Learning!!!
Few things I would like to add to this post.
1. I am not sure why we are using deployer.cmd. To install custom jar, we just need to run install3rdParty.cmd. deployer.cmd will be used if we want to add extensions(table columns or new custom tables) or resources(like templates).
2.One method is already described here i.e. whenver new code needed to be deployed, user needs to export the jar from eclipse, replace in the smcfs.ear deployed in jboss and restart jboss. There is one more way which is easier than this.
Just like we extraced the ear, extract the SterlingCustom94.jar into a folder and rename the folder as SterlingCustom94.jar (Folder should have .jar extension)
Right click on project. Go to Properties/Java build path/ Source tab.
In the bottom Click on Browse, choose your project top folder, click on Create new folder–>Advanced–>Check link folder to System–>Browse and select the jar folder which you extracted in smcfs.ear. Click on Apply.
3. Basically what this complete step does is changing the folder where the project classes will be complied. So whatever code changes are done, the latest class files will be generated directly in the jar present in the ear.
4. Make the changes, restart the server and voila. No jar export, replace in ear required.
Hi yashu,
Thanks lot for comments and contributions. We will update the post with your suggestions. One more time thanks for all your support.
Regards
Active kite admin
Please provide all the step to install on weblogic Please. very nice post.. i have done installation on Jboos.but not able to do on weblogic so pls help..
Aman
We have document how to download and install weblogic and creating domain. Will share with you. Soon will post video version on the same.
Regards
Admin
Aman,
we have uploaded weblogic install and domain creation for you.
https://www.youtube.com/watch?v=6OmiQpcnVS0
Please watch and share your feedback. Thanks
Thanks!
Pingback: Sterling OMS Custom Table Creation - Learn IBM Sterling Order Management System
Pingback: Sterling OMS Adding New Column - Learn IBM Sterling Order Management System