SAP / cloud-sdk

The SAP Cloud SDK documentation and support repository.
https://sap.github.io/cloud-sdk/
Apache License 2.0
44 stars 41 forks source link

Problems Use com.sap.cloud.connectivity.apiext Migratin NeoService to CF #1366

Closed arkand2 closed 1 year ago

arkand2 commented 1 year ago

Hello everyone,

Issue Description

I'm trying to migrate a service from a NeoEnvironment to CloudFoundry. I'm using the latest version of the SAP Java Cloud SDK, but I'm having some problems with dependencies.

The original service imported and used the following dependencies:

import com.sap.core.connectivity.api.authentication.AuthenticationHeader;
import com.sap.core.connectivity.api.authentication.AuthenticationHeaderProvider;
import com.sap.core.connectivity.api.configuration.ConnectivityConfiguration;
import com.sap.core.connectivity.api.configuration.DestinationConfiguration;

I found a PDF manual from SAP BTP Connectivity Service with a date of April 19, 2023 for Cloud Foundry, which mentions using the following dependency:

https://help.sap.com/doc/92c0b171cceb4db2a93518b34b84febd/Cloud/en-US/connectivity_service.pdf

<dependency>
<groupId>com.sap.cloud.connectivity.apiext</groupId>
<artifactId>com.sap.cloud.connectivity.apiext</artifactId>
<version>${connectivity-apiext.version}</version>
<scope>provided</scope>
</dependency>

However, when I try to build the project, I receive the following error:

[ERROR] Failed to execute goal on project XXXX-application: Could not resolve dependencies for project XXX:XXXXXX-application:war:1.0-SNAPSHOT: Failed to collect dependencies at com.sap.cloud.connectivity.apiext:com.sap.cloud.connectivity.apiext:jar:3.21.0: Failed to read artifact descriptor for com.sap.cloud.connectivity.apiext:com.sap.cloud.connectivity.apiext:jar:3.21.0: com.sap.cloud.connectivity.apiext:ConnectivityAPIExtParent:pom:3.21.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

I've tried adding the dependency to the application's pom, and if I use it in an external pom2, it doesn't give this error, but the dependency is not resolved.

Impact / Priority

Affected development phase: Development

Impact: Blocked

Timeline: N/A

Error Message

N/A

Project Details

This service is used for convert data from ui5 apps to CPI service.


Checklist

newtork commented 1 year ago

Are you sure, you're using SAP Cloud SDK? None of the mentioned dependencies are related to SAP Cloud SDK (com.sap.cloud.sdk).

arkand2 commented 1 year ago

Hi @newtork,

Sure. I generated this app with this maven archeatype.

mvn archetype:generate "-DarchetypeGroupId=com.sap.cloud.sdk.archetypes" \ "-DarchetypeArtifactId=scp-cf-tomee" \ "-DarchetypeVersion=RELEASE"

This is my pon in root app directory.

`<?xml version='1.0' encoding='utf-8'?>

4.0.0 testXXX - Root testXXX - Root XXX testXXX 1.0-SNAPSHOT pom local-deployment deployment local sdk-bom com.sap.cloud.sdk ${sdk-bom.artifactId} 4.13.0 pom import junit junit 4.13.2 test ch.qos.logback logback-classic 1.2.11 runtime 1.8 sdk-sjb-bom ${java.version} ${java.version} ${java.version} ${java.version} UTF-8 UTF-8 UTF-8 application integration-tests org.apache.maven.plugins maven-pmd-plugin 3.20.0 rulesets/java/maven-pmd-plugin-default.xml org.apache.maven.plugins maven-enforcer-plugin 3.3.0 SAP Cloud SDK Project Structure Checks enforce 3.5 ${java.version} project.artifactId [^_]+ "The artifactId should not contain underscores (_) as this causes issues when deploying to Cloud Foundry." true

`

and this is from my application directory.

`<?xml version='1.0' encoding='utf-8'?>

4.0.0 testXXX - Application testXXX - Application testXXX-application 1.0-SNAPSHOT war XXX testXXX 1.0-SNAPSHOT false 1 * 1024m info -Xmx${surefire.maxMemorySize} -Dorg.slf4j.simpleLogger.defaultLogLevel=${surefire.logLevel} ${project.build.directory}/coverage-reports/jacoco.exec * org.apache.* com.google.guava guava org.checkerframework checker-qual com.sap.cloud.sdk.cloudplatform scp-cf com.sap.cloud.sdk.s4hana s4hana-all com.sap.cloud.sdk.cloudplatform security-servlet runtime com.sap.cloud.connectivity.apiext com.sap.cloud.connectivity.apiext ${connectivity-apiext.version} provided org.slf4j slf4j-api org.slf4j jcl-over-slf4j runtime ch.qos.logback logback-classic javax.inject javax.inject provided javax.servlet javax.servlet-api provided junit junit ${project.artifactId} org.apache.maven.plugins maven-war-plugin 3.3.2 true org.jacoco jacoco-maven-plugin 0.8.9 ${jacoco.executionDataFile} ${jacoco.executionDataFile} ${jacoco.includes} ${jacoco.excludes} prepare-agent prepare-agent org.apache.maven.plugins maven-surefire-plugin 3.0.0 ${surefire.skipTests} ${surefire.include} ${surefire.exclude} ${surefire.forkCount} false ${surefire.groups} ${surefire.excludedGroups} ${project.build.directory}/surefire-fork/${surefire.forkNumber}/ local-deployment deployment local ${project.artifactId}-local org.apache.tomee.maven tomee-maven-plugin 8.0.14 webprofile ROOT remove:slf4j-jdk14 8006

`

Thanks in advance

newtork commented 1 year ago

I'm seeing that com.sap.cloud.connectivity.apiext:com.sap.cloud.connectivity.apiext:3.21.0 has a parent module com.sap.cloud.connectivity.apiext:ConnectivityAPIExtParent:3.21.0 which is not available on Maven Central.


SAP Java Buildpack offers and declares some dependency that are only available company internally: https://github.wdf.sap.corp/xs2-java/xs-java-buildpack/blob/3608d6db1fbdc188b3097c36c5bbe912ebff7d76/resources/pom.xml#L67

If you want to use them, please understand the following limitations:

Kind regards Alexander

arkand2 commented 1 year ago

Thank you Alexander.

I can't access this link. I guess this gitHub is only available for SAP employees because of what you say. The host not reached.

the external employees cannot access to resolve this depencency, rigth?

Thanks in advance.

MatKuhr commented 1 year ago

Yes the links are internal only, but they are not required to use the SAP Java Buildpack, as the Buildpack is accessible all SAP BTP users.

arkand2 commented 1 year ago

Hi all again,

But I dont understand how i can resolve the dependency. Could you give me an example please?

I need to compile the maven proyect before deploy and for that I need to resolve the depencecy first, right?

Thanks in advance.

MatKuhr commented 1 year ago

Hi, sorry I think I missed an important point in your question. I think you probably need the classes contained in com.sap.cloud.connectivity.apiext at compile time? Typically, if a scope provided is given, the classes are needed at runtime only. But I assume in this case they are also needed at compile time?

If so, then I think this might currently not be possible, because the relevant parent POM seems to be missing on Maven Central. I suspect this is an oversight. But the relevant dependency is not part of the SAP Cloud SDK, so I can't give a definitive answer on that.

Which functionality are you using on Neo at the moment? Are you only reading destinations, or also creating / updating / deleting them?

arkand2 commented 1 year ago

Hello, sorry for the delay. I was on holiday. We finally implemented this logic in a CPI service, but you are right, we only use it to read the description and then use it.

Thanks for everything.