Skip to Content
Former Member
Jul 30, 2009 at 08:57 AM

Automatic ear deployment to Netweaver server (for example with Maven)



<p>In past I used the SAP tools Visual Administrator and/or Deployment Manager to deploy enterprise applications (EARs) manually to Netweaver AS 7. We use Maven as build tool, even for Netweaver applications. Unfortunately we didn't find any plugin that automates that deployment. So I have developed my own plugin using the Deployment Manager that you can find on any SAP Netweaver 7 installation at &lt;path-to-netweaver-instance&gt;/j2ee/deploying.


<p>In this forum thread I want to present you how to develop such a plugin on your own.


<p>In the sapj2eenginedeploy.jar you can find the class DeployManagerImpl that you can call within an own Maven mojo (plugin) or ant task. The constructor needs an XML configuration file where you define the EAR-file to deploy and connection data (host, user, password). Other dependent libraries for runtime are the j2eeclient jars (<path-to-netweaver-instance>/j2ee/j2eeclient/*.jar) that has to be added to your classpath.



DeployManagerImpl deployManager = new DeployManagerImpl("ear-deploy-config.xml", null, "workDir");


EARDescriptor earDescr = deployManager.getEarDescr();

String appID = earDescr.getApplicationID();

System.out.println("Deploy applicationID=" + appID);

deployManager.update(); // or .deploy()





The XML file is described at sap help: deploymanager-config.dtd">deploymanager-config.dtd> .For example you can use this simplified XML (here with maven properties ${} that are filtered within a maven plugin):



&lt;?xml version="1.0" encoding="UTF-8" ?&gt;&lt;!DOCTYPE deploy-manager-config []&gt;


















&lt;property&gt;container_type = B&lt;/property&gt;





You can write a Maven mojo using this DeployManagerImpl class to automate deployment issues, see guide" target="_blank">">guide java plugin development and

DeveloperCookbook">mojo developer cookbook</a>. Your mojo could read a given XML config and filters the dynamic properties (at least path to ear-file) or generate the XML config file on its own.


<p>We suggest to implement different Maven goals for "deploy", "update", "start", "stop" etc. Then you can include such a plugin in your Maven build, for example here an pom.xml snippet to package an ear. You can build with profile 'sapdeploy' to deploy your ear to Netweaver server within pre-integration-test phase.




































Have fun.