(SM-24II) Java Connector Setup

Java connector is a component used for authentication and communication with remote services using JDBC drivers or Java SDKs. It runs as an independent OS process and can be configured and controlled through transaction /DVD/JCO_MNG.

By default, the Java connector is deployed directly on the SAP ABAP application server and can be managed from the SAP GUI.
If the application server's operating system is Linux x64 or Windows x64, the setup is straightforward.
If SAP runs on a different operating system or architecture, please follow additional steps in Using custom Java Runtime.

In this section:

image-20240226-092415.png

Transaction /DVD/JCO_MNG

 

/DVD/JCO_MNG is the interface for the Java Connector (JCO) management.
When the transaction is opened for the first time, a pop-up window asks whether the JCO is going to be deployed locally or if there is a standalone JCO installation that is only going to be monitored.
The crucial configuration parameter is the SAP RFC destination which will be used as a communication channel between SAP and JCO.
In the case of a standalone JCO, the interface only allows checking whether the JCO is up and connected, but the configuration and operation are done remotely (for more information, see the chapter https://datavard.atlassian.net/wiki/spaces/ReuseLib/pages/4154982750).

Table of Contents:

Prerequisites

SAP RFC role and user

Java connector uses a dedicated user in the SAP system for registration on the SAP gateway and further communication between ABAP and Java.
This user should be created with the type System and with authorizations limiting his privileges to basic RFC communication.

Predefined role /DVD/JCORFC is included in the software and can be used as is, or as a template for the custom role.

The required authorization object is S_RFC with these settings:

  • ACTVT = 16

  • RFC_NAME = RFC1, RFC_METADATA, SDIFRUNTIME, SYST

  • RFC_TYPE = FUGR

Java Connector RFC

Java Connector RFC is used to reference the Java service registered on the SAP gateway. Use the template below as a reference.

Settings:

  • Connection Type: T for TCP/IP Connection

  • Activation Type: Select Registered Server Program

  • Program ID: Name of the program how JCO will identify itself when logged on to SAP gateway (Example: SNP_CONNECTOR)

SAP Gateway Access (reginfo)

External communication with the SAP system goes through the SAP gateway. If the SAP system parameter gw/acl_mode is enabled, there are files reginfo that limit the access of external programs.
In this case, a program needs to have granted access either by wildcard definition or by explicitly defining the program registration name (in our example it is SNP_CONNECTOR).

More information on the SAP gateway ACL topic can be found on the SAP website Gateway Security Files secinfo and reginfo.

Initial setup

  1. Enter transaction /DVD/JCO_MNG,

  2. Select the latest JCO version by double-clicking the row on the left side of the screen,

  3. Switch to Edit mode,

  4. Click Fill default values,

  5. Fill in RFC Destination in the General tab.

     

  6. Fill in Technical user Credentials in the Config tab.
    Optionally, customize the Install directory. Logical path </DVD/DEF_JCO_DIR> translates to /usr/sap/<SID>/<instance_dir>/work/dvd_conn/.
    If multiple application servers are used, the installation directory must contain </DVD/DEF_JCO_DIR> to enable deployment to the appropriate path containing the INSTANCE directory on each app. server.

     

  7. Select the latest library bundle in Libraries.

     

  8. Go back to the General tab, Save, and click Restart to deploy the JCO.

     

  9. (Optional) Set Proxy settings in the Config tab. A JCO restart is required after configuring the proxy.

Proxy parameters description

  • Use Proxy: Enable or disable the use of a proxy server.

  • Enable HTTPS: Set the HTTPS protocol for the proxy connection.

  • Proxy Host: The hostname or IP address of the proxy server.

  • Proxy Port: The port number on the proxy server to connect.

  • Proxy User: Username for authentication with the proxy server.

  • Proxy PW: Password for authentication with the proxy server.

  • Non-proxy Hosts: A list of hosts to bypass the proxy server.

 

In a scenario with multiple SAP application servers, the initial deployment must be done locally on each app. server.
Switch to the respective application server using transaction SM51.

 

Advanced parameters description

  • OS Command for starting Java service: Name of an OS command for starting Java service (SM69).

  • OS Command for setting access permissions: Name of an OS command for setting execution rights (SM69).

  • OS Command for 7Zip: Name of an OS command for unpacking libraries and embedded JRE (only if embedded JRE is chosen) (SM69).

  • Max RAM used: Maximum amount of system memory used by Java service (heap size).

  • Additional Java starting arguments: Additional arguments used to start the Java service.

  • Repository destination: Client destination from which repository should be obtained (always defaults to ABAP_AS_WITH_POOL).

  • Work thread MIN: Number of threads Java Virtual Machine always runs with.

  • Work thread MAX: Maximum number of threads that the Java Virtual Machine can spawn.

  • Connection count: Number of connections registered at SAP gateway. The default is 10 and the maximum number of connections per JCO instance is 100.

  • Peak limit: Limit of JCO connections at peak.

  • Log4j log level: Level of messages collected in logs, default is INFO.

  • Log4j log deletion: JCO log retention period in days.

  • Log files path: Directory where the log files will be saved.

  • JAR path: Path where the JCO JAR file will be created.

  • Log4j config path: Path where the log4j config file will be created.

  • Server config path: Path where the JCO server config will be created.

  • Destination config path: Path where the JCO destination config will be created.

  • Avoid JCO config file creation: Special option that prevents automatic overwrite of existing configuration files during JCO start. Useful for cases when manual modification of configuration files is needed (troubleshooting).

  • Use JCO dir for parquet conversion: If required, JCO performs data conversion into PARQUET format. This is by default done in memory; when this option is active, conversion is done using temporary files in the <JCO_install_dir>/parquet subdirectory. This may be necessary if the memory allowance for JCO is limited.

  • Embedded JRE: Path to embedded JRE (nested in Install directory in Config Tab <JCO_install_dir>).

  • Use custom JRE: Checkbox whether or not to use custom JRE for JCo, if the checkbox is not checked, then embedded JRE is used.

  • Custom JRE: Path to custom JRE, executable by <sid>adm user. 

Using custom Java Runtime

As of SNP Reuse Library version 22.08, the SNP Java connector comes with regularly updated embedded Java runtime (Adoptium 11) for Linux 86_x64 and Windows x64 and no manual setup is required in this regard.

If the SAP system runs on different operating system (Solaris, AIX, HPUX, etc.), or it is not desired to use the embedded JRE, then custom JRE and libsapjco3 libraries need to be deployed to the application server(s) manually.

Java runtime environment (JRE)

Recommended JRE is the latest version of OpenJDK 11. OpenJDK JRE can be downloaded from the Adoptium download site for most architectures.

Not to interfere with possible Java installation already present on the SAP application server, the archive can be simply unpacked into any directory accessible to <sid>adm, e.g. /sapmnt/<SID>/global/JRE_11/.

The option to choose between embedded JRE and custom JRE can be found in the Advanced Tab of /DVD/JCO_MNG transaction:

Parameters:

  • Embedded JRE: Path to embedded JRE Java binary. It is by default nested in the JCO Installation directory defined in the Config Tab.

  • Use custom JRE: Checkbox whether or not to use custom JRE. In the default configuration, the checkbox is unchecked, so embedded JRE will be extracted in the default path.

  • Custom JRE: Path to custom JRE Java binary.

SAP Java Connector Library

Java Connector uses a shared library published by SAP named libsapjco3.so (or sapjco3.dll on Windows OS).
Starting with SNP JCo version 229, the library is included in SNP transports for Linux 86_x64 and Windows x64.
If the system hosting JCo is running on an OS other than Linux 86_x64 and Windows x64, it is necessary to manually download and replace the library after the first attempt to start the JCo.
The first start attempt will fail due to incompatibility, but it will deploy all other libraries and configuration files needed for the JCo run. The location of the libraries is /<installation_directory_path>/lib/.

The SAP Java connector library can be downloaded atSAP Java Connector.

Once uploaded to the application server(s), after the first startup attempt (see below), simply replace the library and change the ownership to <sid>adm:sapsys, for example:

cp libsapjco3.so /usr/sap/NSD/DVEBMGS01/work/dvd_conn/jco2402/lib/ chown nsdadm:sapsys /usr/sap/NSD/DVEBMGS01/work/dvd_conn/jco2402/lib/libsapjco3.so

Central Java instance

It is possible to deploy a single JCO instance, instead of running one on every application server. To set up such a scenario, follow these steps:

  1. If the Java connector is already running on several application servers, stop all instances.

  2. Open the Java RFC destination and fill in the Gateway options valid for the desired instance.

     

  3. When the transaction /DVD/JCO_MNG is reloaded, only buttons next to the application server hosting the JCO are functional and all the other app. servers will be using this connection.
    When the JCO is started, all rows in the Connection column should be green, indicating that every application server can reach the JCO via the designated RFC destination.

Setting up the connection via proxy server

Sometimes communication with a service outside the corporate network needs to be routed through a proxy server to comply with company security standards.

To achieve this, the following parameters need to be added to the Additional Java starting arguments field in the Advanced tab of /DVD/JCO_MNG.

-Dhttps.useProxy=true -Dhttps.proxyHost=<proxy_host> -Dhttps.proxyPort=<proxy_port>

There is a chance that the proxy server is configured to communicate in plain HTTP protocol. In that case, the parameters need to reflect that, using:

-Dhttp.useProxy=true -Dhttp.proxyHost=<proxy_host> -Dhttp.proxyPort=<proxy_port>

Custom destination for JCO lock file

The lock file is used to prevent the accidental start of multiple JCO instances. By default, the lock file is created in the Installation directory.
If needed, the directory can be changed, using the parameter -DremoteLockFileDir=<ChosenDirectory>.

SNC configuration

If the SAP system is hardened by enabled Secured Network Communication (system parameter snc/enable = 1), there are additional configuration steps.

  1. The first step is the creation of a Personal Security Environment (PSE) for the JCO. This is to be done under <sid>adm user.
    PSE should be stored together with other SAP PSE files, by default on path /usr/sap/<SID>/<SAP_instance>/sec, referenced by the environment variable $SECUDIR.
    Commands to create the PSE, with an example of system ID NSD with csh as nszadm’s shell:
    su - nsdadm
    setenv SECUDIR /usr/sap/NSD/D00/sec
    cd $SECUDIR
    sapgenpse gen_pse -v -p SNPJCO.pse

    A passphrase can optionally protect PSE. The mandatory input parameter is the Distinguished name of the PSE owner, in our example, it’s CN=SNPJCO, OU=SNP, C=DE

     

  2. The second step is to export the certificate with the public key from the newly created PSE, using the command:
    sapgenpse export_own_cert -v -p SNPJCO.pse -o SNPJCO.crt
    This produces SNPJCO.crt file.

     

  3. Now import the SNP JCO certificate file into the SAP system’s Trust manager.
    Run transaction STRUST > switch to Edit mode > double-click SNC PSE node > in the lower part of the screen click on the Import certificate icon, locate the certificate file, confirm file selection > click Add to Certificate List > Save (Ctrl+S)
    NOTE: You may need to download the certificate file to your front end to be able to select it.

  4. We have imported the JCO certificate to SAP. To create two-way trust between SAP and JCO, we now need to import the SAP system’s certificate to JCO PSE.
    Export SAP’s certificate, similarly as in step 3. Run STRUST and select the SNC PSE node, but double-click on Own certificate, and at the bottom of the screen click the icon Export certificate. Choose Base64 format, path, and filename to save the .crt file. Upload the file to the application server, ideally to $SECUDIR.

  5. To import the SAP certificate to JCO PSE, run the command:
    sapgenpse maintain_pk -v -a SAP.crt -p SNPJCO.pse

     

  6. To allow JCO to run under <sid>adm user using the credentials stored in the PSE, SSO credentials must be created in the cred_v2 file.
    It is advised to back up the cred_v2 file before proceeding.
    The file should already exist in SECUDIR and will be updated using the command:
    sapgenpse seclogin -p SNPJCO.pse -O nsdadm

    If the SAP system is distributed, the PSE file and SSO credentials allowing access to it in cred_v2 need to be present on each application server.

     

    NOTE: If JCO is deployed in a Windows environment, allow access to the PSE file also for user SAPService<SID>.
    example: sapgenpse seclogin -p SNPJCO.pse -O SAPServiceNSD

    Available SSO credentials can always be checked using the command:
    sapgenpse seclogin -l

  7. Now that the security environment is prepared, configure JCO SNC in transaction /DVD/JCO_MNG in the Config Tab:

     

    • SNC enabled: Once activated, user and password fields will be greyed out and have no effect on JCO configuration.

    • SNC QoP Level: SNC Quality of Protection, needs to be the same level as set in system parameter snc/data_protection/use (default = 3).

    • SNC name: Distinguished name chosen during the creation of JCO PSE (step 1).

    • SNC-enabled GW port: SAP gateway port used for secure communication. Do not change the default value 48$$, $$ is automatically translated to the instance number of a particular application server.

    • SNC partner name: Distinguished name of SAP system, pre-filled from SAP profile parameter snc/identity/as.

      Save the configuration when completed, but do not start the JCO yet.

  8. There are two more configuration pieces to complete before JCO can properly start and register on the SAP gateway.
    In SU01, activate SNC for RFC user dedicated to JCo communication, filling in the SNC name dedicated to JCo.
    Despite the user no longer being configured in /DVD/JCO_MNG, it is used by matching the SNC name entered here and the Distinguished name configured in JCo PSE.

     

    Secondly, via SM59 activate SNC in the RFC destination dedicated to communication between SAP and JCO and fill in the JCo Distinguished name again in the Logon & Security tab (SNC options button):

     

    Having all SNC prerequisites met, Java Connector can be started.

Sample JCo configuration files with SNC enabled

Configuration files example:

Upgrading Java connector

This is a list of steps to do when you update your SNP software and you would like to switch to a new version of the Java connector.

  1. Open transaction /DVD/JCO_MNG

  2. Double-click the current working connector and click Stop all.

     

  3. After the current version of the SNP Java connector is disconnected, click Copy config.

     

  4. Double-click the new version of the connector, enter Edit mode, then click Paste config, then fill the RFC Usage field with the same RFC that was used with the old connector.

     

  5. Switch to the Config tab and adjust the Install directory to match the current version of the SNP Java Connector.

     

  6. Switch to the Libraries tab and make sure you are using the latest libraries for your connector.

     

  7. Navigate back to the Config tab and click on the Generate paths button, afterwards save the configuration.

  8. Switch back to the General tab and click Restart all.

     

 

Automatic Java connector startup after SAP system restart

For the automatic start of the Java connector after the SAP system restarts, schedule a periodic job with program /DVD/JCO_WATCH_DOG with start condition: “SAP_SYSTEM_START“.

Copying Java connector

Sometimes it may be needed to COPY the JCO instance and create a version from it.
When the JCO is copied, the separate JCO installation directory is used; the new JCO instance thus has its own space for configuration and logs.

Possible use cases for JCO COPY:

  • Vertical scaling: When more JCO instances are needed.

  • Versioning: When the JCO is needed for a different purpose.

  • JCO testing: To make different instances for testing purposes.

  1. Open transaction /DVD/JCO_MNG.

  1. Click on Copy JCO.

  • Copy config from Java RFC: Copies JCO configuration from the JCO configured with selected RFC destination.

  • Copy config from version ID: Copies JCO configuration from given JCO ID.

  • Use default values: Uses defaults for the new JCO.

  • Java version: Read-only field as a newly created copy of JCO will be created from a particular Java version.

  • Description: Description of a newly created copy of JCO.

  1. Example of the JCO copy, reconfigured with appropriate parameters - most importantly RFC destination and Installation directory.