cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

Hello!

<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>

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

</p>

<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.

</p>

<p><pre>

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

deployManager.setLog("deploy-log.txt");

EARDescriptor earDescr = deployManager.getEarDescr();

String appID = earDescr.getApplicationID();

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

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

deployManager.startApplication(appID);

deployManager.stopApplication(appID);

deployManager.undeploy(appID);

</pre></p>

<p>The XML file is described at sap help: <a href="http://help.sap.com/saphelp_nw04/helpdata/en/29/4d1fe8f8f4124db04ac1a24c4a1246/frameset.htm">deploymanager-config.dtd</a> .For example you can use this simplified XML (here with maven properties ${} that are filtered within a maven plugin):

</p>

<p><pre>

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

&lt;deploy-manager-config&gt;

&lt;deployable-object&gt;

&lt;ear-file&gt;

&lt;ear-path&gt;${project.build.directory}/${project.build.finalName}.ear&lt;/ear-path&gt;

&lt;/ear-file&gt;

&lt;/deployable-object&gt;

&lt;login-info&gt;

&lt;host&gt;${sapdeploy.host}&lt;/host&gt;

&lt;port&gt;50004&lt;/port&gt;

&lt;transport-protocol&gt;None&lt;/transport-protocol&gt;

&lt;user-name&gt;${sapdeploy.user}&lt;/user-name&gt;

&lt;user-password&gt;${sapdeploy.password}&lt;/user-password&gt;

&lt;/login-info&gt;

&lt;supports&gt;

&lt;support&gt;p4&lt;/support&gt;

&lt;/supports&gt;

&lt;deployment-properties&gt;

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

&lt;/deployment-properties&gt;

&lt;log-file&gt;\deployer_log.txt&lt;/log-file&gt;

&lt;/deploy-manager-config&gt;

</pre></p>

<p>You can write a Maven mojo using this DeployManagerImpl class to automate deployment issues, see <a href="http://maven.apache.org/guides/plugin/guide-java-plugin-development.html">guide java plugin development</a> and <a href="http://docs.codehaus.org/display/MAVENUSER/MojoDeveloperCookbook">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>

<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.

</p>

<p><pre>

&lt;project

...

&lt;packaging&gt;ear&lt;/packaging&gt;

...

&lt;profiles&gt;

&lt;profile&gt;

&lt;id&gt;sapdeploy&lt;/id&gt;

&lt;build&gt;

&lt;plugins&gt;

&lt;plugin&gt;

&lt;groupId&gt;de.conet.products.maven.plugins&lt;/groupId&gt;

&lt;artifactId&gt;maven-sapdeploy-plugin&lt;/artifactId&gt;

&lt;version&gt;1.0.0&lt;/version&gt;

&lt;configuration&gt;

&lt;configFile&gt;src/main/sapdeploy/deploy-ear-config.xml&lt;/configFile&gt;

&lt;/configuration&gt;

&lt;executions&gt;

&lt;execution&gt;

&lt;phase&gt;pre-integration-test&lt;/phase&gt;

&lt;goals&gt;

&lt;goal&gt;update&lt;/goal&gt;

&lt;goal&gt;start&lt;/goal&gt;

&lt;/goals&gt;

&lt;/execution&gt;

&lt;/executions&gt;

&lt;/plugin&gt;

&lt;/plugins&gt;

&lt;/build&gt;

&lt;/profile&gt;

&lt;/profiles&gt;

&lt;/project&gt;

</pre></p>

<p>

Have fun.

</p>

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Dirk Weigand,

Really a good one from you......superb job for narrating the concept.

Please update us with related concepts

thank you

Regards,

Anand