MuleSoft SAP Connector
- February 14, 2020
Stuck while resolving issues with dependency and configurations with SAP Connector? Check out some easy and handy points if you’re a naive user to SAP.
Firstly, if you want to connect to SAP via MuleSoft you can use the ready-to-go SAP Connector, or you can connect the traditional way using Web Service Consumer.
We’ll see how to get connected to SAP using Mulesoft SAP Connector. I’ll be using sRFC Function to invoke the BAPI Function call.
As a MuleSoft professional and a newcomer in SAP, you might hear various acronyms. There’s a chance you might get confused or scared so don’t forget to check out SAP acronyms before you panic.
Once you’ve pulled out SAP Connector from Mule Palette, this is what your configurations will look like.
Connector configurations
While configuring the connector you can opt for one of the two either select “Certificate” or “Simple Connector Provide.” I’ve chosen the latter.
Then comes the most important part (i.e configuring libraries). You need to be careful while choosing libraries.
First, two libraries that are IDoc Library and Jco Library are pretty straightforward and jar files are available for them.
For Jco Native Library, you need to import Library which is in .so format if you’re deploying to CloudHub or Linux based OS system.
CloudHub workers are based on Linux 64 bits virtual machines, running on an Intel/AMD 64 bits architecture (x86_64). So in order to avoid the error in Cloudhub, you need to add the native library for Linux x86 64 bits (libsapjco3.so) with the type so.
Jco native Library is dependent on the operating systems. It’ll vary for different operating systems.
# This is for Mac Only
mvn install:install-file -DgroupId=com.sap.conn.jco -DartifactId=libsapjco3 -Dversion=3.0.18 -Dpackaging=jnilib -Dfile=libsapjco3.jnilib
# This is for Windows Only
mvn install:install-file -DgroupId=com.sap.conn.jco -DartifactId=libsapjco3 -Dversion=3.0.18 -Dpackaging=dll -Dfile=sapjco3.dll
# This is for Linux Only
mvn install:install-file -DgroupId=com.sap.conn.jco -DartifactId=libsapjco3 -Dversion=3.0.16 -Dpackaging=so -Dfile=sapjco3.so
With above dependency installed lets change pom.xml,
Add below shared libraries :
<sharedLibraries>
<sharedLibrary>
<groupId>com.sap.conn.idoc</groupId>
<artifactId>com.sap.conn.idoc.sapidoc3</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>com.sap.conn.jco</groupId>
<artifactId>com.sap.conn.jco.sapjco3</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>com.sap.conn.jco</groupId>
<artifactId>libsapjco3</artifactId>
</sharedLibrary>
</sharedLibraries>
In the dependencies section in the pom.xml file, add the SAP libraries dependencies
<dependency>
<groupId>com.sap.conn.idoc</groupId>
<artifactId>com.sap.conn.idoc.sapidoc3</artifactId>
<version>3.x.x</version>
</dependency>
<dependency>
<groupId>com.sap.conn.jco</groupId>
<artifactId>com.sap.conn.jco.sapjco3</artifactId>
<version>3.x.x</version>
</dependency>
<dependency>
<groupId>com.sap.conn.jco</groupId>
<artifactId>libsapjco3</artifactId>
<version>3.x.x</version>
<classifier>external-library</classifier>
<type>so</type>
</dependency>
Once you’re done configuring libraries, you’re ready to go to next step and fill in your:
Username, Password, SAP System number (which can be like 100,200 or ),
SAP Client ID and Application Server Host. Once done with your configurations you’re ready to go. Test your connection.
The most common error we get while deploying SAP-based integration to Cloudhub is –
Failed to invoke lifecycle phase "initialise" on object:
org.mule.runtime.module.extension.internal.runtime.config.ConfigurationProviderToolingAdapter@41544bcf
java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path
And it’s mainly due to the use of incorrect libraries.
— By Akshata Sawant