javajcosap-business-technology-platform

Error 500 while deploying JCo project to SCP


I'm trying to connect a RFC to a Dynamic Web Project in Eclipse. The project would be deployed to SCP and I added a destination on SCP like this:

Destination

The project contains a Servlet which executes the below code and those two combined work just fine.

  protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
{
  
    PrintWriter responseWriter = response.getWriter();       
   
    try
    {   
  JCoDestination destination = JCoDestinationManager.getDestination("jcodemo");  
        JCoRepository repo = destination.getRepository();
        JCoFunction rfcConnection = repo.getFunction("ZRFM_GET_EQUIPMENTS");
        rfcConnection.execute(destination);
  
      responseWriter.println("<html><head>");                   
      responseWriter.println("</head><body>");
  responseWriter.println("<p>Test</p>");
        responseWriter.println("</body></html>");
  
    }

}

I want to alter the destination at runtime (to let users use their own account), so I added a DestinationDataProvider. It is used in multiple guides who make custom destinations. (I left it empty to save some space, its functionality doesn't matter here.)

    public class DestProvider implements DestinationDataProvider {

    @Override
    public Properties getDestinationProperties(String arg0) throws DataProviderException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void setDestinationDataEventListener(DestinationDataEventListener arg0) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public boolean supportsEvents() {
        // TODO Auto-generated method stub
            return false;
        }
    
    }

In order for Eclipse to recognize the import com.sap.conn.jco.ext.DestinationDataProvider, I added the SAPJCo3.jar as a reference to the project. I didn't need the import before this part.

Reference

I added this piece of code to my Servlet to instantiate one. The second I reference this in the Servlet, the webpage returns a 500 error.

    DestProvider d = new DestProvider();

I've tried all sorts of things, but I keep getting an error. The logs of the Java application are empty as well, so I do not have any idea on how to continue with this. Any help will be greatly appreciated.


Solution

  • You cannot register your own DestinationDataProvider on the SAP Cloud Platform. sapjco3.jar is the standalone SAP Java Connector and is not suitable to be used/deployed on the SCP. This platform already comes with all the necessary artifacts including a special JCo client version. The RFC connectivity to on-premise SAP systems is achieved via a TLS tunnel to the SAP Cloud Connector.

    Maybe this tutorial helps with understanding the architecture and how to use JCo RFCs on the SAP Cloud Platform:
    https://www.sap.com/germany/developer/tutorials/hcp-scc-onpremise-extension-jco-rfc.html

    For custom JCo destinations you should be able to use the class JCoCustomDestination which will allow to switch user logon credentials, but not to change the logon parameters which define the target SAP system.