Deploy SAP Java applications
To deploy a SAP Java application like Web Dynpro Java or SAP Portal application, tools like NWDS, NWDI or telnet are used. This is a very SAP centric setup. But how can you deploy a WDJ application without using NWDI, NWDS, telnet or direct server access? What if you want to deploy it out of your continuous integration (CI) server?
EAR, SDA, WAR, PAR, SCA?
First question to ask and to answer is: what file can be deployed? Normally, SAP Java applications are in SCA or SDA format. Standalone WDJ applications are EAR and portal files are SDA. The good news is that they are ZIP files. The portal SDA is basically the old PAR file renamed to SDA and WDJ EAR files are … EAR files. NWDS will create the files correctly, it’s just picking these files up – or create them manually – and deploy them to NW Java.
Note for WDJ EAR and SDA transformation
On releases 7.1 and higher, .EAR files are automatically converted to SDA format during deployment. [SAP Note 1715441 – How to deploy .SDA / .EAR files on J2EE servers on Netweaver release 7.1 and higher]
In NWDS 7.1 versions there was a folder with ant scripts provided.http://help.sap.com/saphelp_nwce711/helpdata/en/46/150746f21914dce10000000a155369/content.htm
This folder and therefore the tools are gone in newer NWDS versions. Basically, there are no client side tools provided by SAP to deploy an application without using a SAP tool. The SAP Note 1715441 contains all the information regarding on how to deploy an application. It contains one entry about a deployment script:
Using filesystem deployment script
- Open the “deployment script” folder located in /usr/sap/<SID>/J<nr>/j2ee/deployment/scripts.
- Run the command “deploy.bat <user>:<password>@<host>:<port> <archive location>” (For example on a windows server, run “deploy.bat hemadm:initial1d@pwdf3341:50004 C:\testsda.sda”
Taking a look at the mentioned deployment directory unveils:
There is an ant directory with an example ant build file. You can take this script and try it out to see if it matches your needs. In my case it didn’t. The SAP Note mentions a script directory; let’s take a look at it:
Running the deploy.csh script shows the application help.
Doing a deploy from the cmd line on the server:
Great, it works! But only from the server. What about freedom and deploy WDJ / Portal applications from your CI?
A look inside the file reveals that deploy.csh is a wrapper for calling a Java application. To be able to trigger a deploy from anywhere you want, all it takes is a Java application with the required JAR files. All the JAR files can be found in the deployment dir:
The JAR files are:
The Java class to call is
Copy these files to a lib directory on the computer from where the deploy will be done. The command to do a deploy of a custom EAR file from command line using Java is:
java.exe -Dserver.parser.inqmy=true -Dproxy=DC -classpath “.;lib/javaee_deployment-1_2-fr-class.jar;lib/sap.com~tc~je~deployment14~impl.jar;lib/ant.jar;lib/sap.com~tc~bl~jarsap~impl.jar;lib/sap.com~tc~sapxmltoolkit~sapxmltoolkit.jar;lib/sap.com~tc~bl~sl~utility~impl.jar;lib/sap.com~tc~je~adminadapter~impl.jar;lib/sap.com~tc~je~clientlib~impl.jar;lib/sap.com~tc~logging~java~impl.jar;lib/sap.com~tc~exception~impl.jar;lib/deploy_lib~sda.jar” com.sap.engine.deployment.DMClient tobias:<password>@nwce73:50004 ./demo.sap.com~tobias~blog~ear.ear
All the JAR files are in one common lib directory and the name of the ear file is demo.sap.com~tobias~blog~ear.ear.
The deploy application expects a certain files and folders structure that is given on the server, but not on the client. My deploy folder looks like:\
- lib-> JAR files, resolved by ivy
- deployment/cfg -> contains one of the config files
- a, b and the rest is created dynamically by the deploy application.
The above Java call can be converted easily into a (ant) script. As such, it is also very easy to integrate into a CI server like Jenkins. There are five parameters that have to be set:
- file to deploy
In Jenkins this is done inside the job configuration by checking “This build is parameterized” and adding parameters:
This gives the option to build the job with parameters:
Inside build.xml these parameters can be referenced using:
This allows to deploy a EAR, SDA file out of your CI server. After a build the application can be deployed and the functional / load test can be run and integrated into the overall CI job run result. Transparency for your SAP Java projects.
A problem is – unfortunately – that the Java program does always return a successful execution as long as the application does not hit an error in the execution flow; like: logon not possible, missing EAR file. When the deploy returns an error, the application still returns success to the ant task, as the execution steps of the deploy application worked. To report a build failure on a failed server side deploy you’ll have to check the logs.