Skip to Content
0

Unable to create destination dynamically though java application in SAP cloud

May 17, 2017 at 06:12 AM

165

avatar image

Hi Experts,

I created one java project in which one of the java file to implement DestinationDataProvider file as below, I am overriding the registerDestinationDataProvider() from DestinationDataProvider.

The corresponding package of the class (com.sap.conn.jco.ext.DestinationDataProvider) DestinationDataProvider has been added to the class path even though I am getting error like java.lang.NoClassDefFoundError: com/sap/conn/jco/ext/DestinationDataProvider.

also note that I am using other classes from the same package for which no exception is thrown like above, please help

package com.acn.rpa.utilities; import java.util.HashMap; import java.util.Map; import java.util.Properties; import com.sap.conn.jco.ext.DestinationDataEventListener; ///import com.sap.conn.jco.DestinationDataProvider; import com.sap.conn.jco.ext.DestinationDataProvider; public class MyDestinationDataProvider implements DestinationDataProvider { Map<String, Properties> propertiesForDestinationName = new HashMap<String, Properties>(); public void addDestination( String destinationName, Properties properties ) { propertiesForDestinationName.put( destinationName, properties ); } public Properties getDestinationProperties( String destinationName ) { if ( propertiesForDestinationName.containsKey( destinationName ) ) { return propertiesForDestinationName.get( destinationName ); } else { throw new RuntimeException( "JCo destination not found: " + destinationName ); } } public void setDestinationDataEventListener( DestinationDataEventListener eventListener ) { // nothing to do } public boolean supportsEvents() { return false; } }

Regards,

Rajesh V

10 |10000 characters needed characters left characters exceeded

Additional Information:

For S4 Auto Config : We are Executing RFC of SAP S/4 System through Java Application using SAP Java Connector (3.0). We are able to connect and execute the RFC using destination defined in HCP.

Problem Statement: Trying to achieve dynamic user id and password creation for destination (which to be configured in HCP). This Dynamic user override is working in Local desktop with apache tomcat. We are facing this issue only in HCP java Environment.

Following the Code Snipped Used:

createDestinationFile(){

Properties connectProperties = new Properties();

connectProperties.setProperty(DestinationDataProvider.JCO_DEST, sapSystemDTO.getDestinationName());

connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, sapSystemDTO.getHostName());

connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, ""+sapSystemDTO.getSystemNo());

connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, ""+sapSystemDTO.getSapClientNo());

connectProperties.setProperty(DestinationDataProvider.JCO_USER, sapSystemDTO.getUserId());

connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, sapSystemDTO.getPassword());

connectProperties.setProperty(DestinationDataProvider.JCO_LANG, sapSystemDTO.getLanguage());

connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "3");

connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");

MyDestinationDataProvider myDestinationDataProvider = new MyDestinationDataProvider();

myDestinationDataProvider.changePropertiesForABAP_AS(connectProperties);

com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(myDestinationDataProvider);

JCoDestination destination = JCoDestinationManager.getDestination(sapSystemDTO.getDestinationName());

JCoRepository repo = destination.getRepository();

JCoFunction stfcConnection = null;

stfcConnection = repo.getFunction("ZRFC");

destination.ping();

}

publicclass MyDestinationDataProvider

implements DestinationDataProvider

{

private Hashtable<String, Properties> propertiesTab = new Hashtable<String, Properties>();

private DestinationDataEventListener eL;

public Properties getDestinationProperties(String destinationName)

{

if(propertiesTab.containsKey(destinationName)){

returnpropertiesTab.get(destinationName);

}

returnnull;

}

publicvoid setDestinationDataEventListener(DestinationDataEventListener eventListener)

{

this.eL = eventListener;

}

void changePropertiesForABAP_AS(Properties pConProps)

{

propertiesTab.put(pConProps.getProperty("jco.client.dest"), pConProps);

}

publicboolean supportsEvents()

{

returnfalse;

}

}

Error Details:

<html><head><title>Error report</title></head><body><h1>HTTP Status 500 - org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/sap/conn/jco/ext/DestinationDataProvider</h1></body></html>

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

RAJESH VALUPADASU Jun 12, 2017 at 09:40 AM
0

This Issue still persists, please let me know if any suggestions

Share
10 |10000 characters needed characters left characters exceeded