I am trying to follow the below links to build a SCP (SAP Cloud Platform) Cloud Foundry application which is using XSUAA (User account and authentication) service, SCP Connectivity service and SCC (SAP Cloud Connector) to consume On-Premise OData service. The below lessons are learned during the prototype.
https://blogs.sap.com/2017/07/09/how-to-use-the-sap-cloud-platform-connectivity-and-the-cloud-connector-in-the-cloud-foundry-environment-part-1/
https://blogs.sap.com/2017/07/13/part-2-how-to-use-the-sap-cloud-platform-connectivity-and-the-cloud-connector-in-the-cloud-foundry-environment/
Maven installation
- Install JDK and set environment variable
JAVA_HOME
- Download Apache Maven and unzip the file
- Add environment variable
M2_HOME
andMAVEN_HOME
- Update environment variable
PATH
for Maven bin folder - Run command
mvn -version
to verify the installation
Reference:
https://www.mkyong.com/maven/how-to-install-maven-in-windows/
http://maven.apache.org/download.cgi
Maven eclipse plugin installation
Please check the below reference links for details. Update site to install Maven plugin in Eclipse:
http://download.eclipse.org/technology/m2e/releases/
Reference:
https://stackoverflow.com/questions/8620127/maven-in-eclipse-step-by-step-installation
http://toolsqa.com/java/maven/how-to-install-maven-eclipse-ide/
Error:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.7.RELEASE from/to Central (http://repo1.maven.org/maven2): Connection refused: connect and ‘parent.relativePath’ points at wrong local POM
Resolution:
- Run the below command in Linux:
find ~/.m2 -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;
Run the below commands in Windowscd %userprofile%\.m2\repository
for /r %i in (*.lastUpdated) do del %i
Then right click on your project in eclipse and chooseMaven->Update Project ...
, make sure “Update Dependencies” is checked in the resulting dialog and click OK. - You can always try
mvn -U clean install
-U Forces a check for updated releases and snapshots on remote repositories - There may be different versions of Maven running between command prompt and Eclipse. Check the Maven installations and Maven user settings in
Eclipse -> Windows -> Preferences
Reference:
https://stackoverflow.com/questions/5074063/maven-error-failure-to-transfer
Error:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Resolution:
- Install JDK instead of JRE
- Set environment variables
JAVA_HOME, classpath, PATH
to link them to JDK, instead of JRE - Check the settings
Windows -> Preferences -> Java ->Installed JREs
in Eclipse. Make sure there is at least one JDK there. Link the Run configuration of Maven build to the JDK
Reference:
Error:
The following artifacts could not be resolved: com.sap.xs2.security:java-container-security-api:jar:0.26.4, com.sap.xs2.security:java-container-security:jar:0.26.4: Failure to find com.sap.xs2.security:java-container-security-api:jar:0.26.4 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
Resolution:
Install XS Security libs to your local Maven repository:
- The first step is to get some additional Java libs from Service Marketplace.
Download additional XS security libs from service marketplace:https://launchpad.support.sap.com/#/softwarecenter/search/XS_JAVA - Unzip the file
- Install XS Security Libs to your local maven repo using:
cd <destLocation>
mvn clean install
Reference:
Error:
The import org.json cannot be resolved
The import org.apache.commons.io cannot be resolved
Resolution:
Download the ZIP file from the below URL and extract it to get the Jar.
Add the Jar to your build path. To Add this Jar to your build path
Right click the Project > Build Path > Configure build path > Select Libraries tab > Click Add External Libraries > Select the Jar file downloaded
http://www.java2s.com/Code/JarDownload/java/java-json.jar.zip
http://commons.apache.org/proper/commons-io/download_io.cgi
Reference
https://stackoverflow.com/questions/8997598/importing-json-into-an-eclipse-project
Error
package json.java does not exist
package org.apache.commons.io does not exist
Resolution
- Run the below Maven command to install the Maven repository
mvn install:install-file -Dfile=java-json.jar -DgroupId=json.java -DartifactId=java-json -Dversion=1.0 -Dpackaging=jar
mvn install:install-file -Dfile=commons-io-2.6.jar -DgroupId=commons-io -DartifactId=commons-io -Dversion=2.6 -Dpackaging=jar
- Add the below dependencies to the pom.xml file
1
2
3
4
5
6
7
8
9
10
11
12<dependency>
<groupId>json.java</groupId>
<artifactId>java-json</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
Reference
Error
Cannot instantiate the type XSTokenRequest
Resolution
- Run the below command to install the Jar file to local Maven repository
mvn install:install-file -Dfile=java-container-security-api-0.26.4.jar -DgroupId=com.sap.xs2.security -DartifactId=java-container-security-api -Dversion=0.26.4 -Dpackaging=jar
mvn install:install-file -Dfile=java-container-security-0.26.4.jar -DgroupId=com.sap.xs2.security -DartifactId=java-container-security -Dversion=0.26.4 -Dpackaging=jar
- Change the pom.xml with the below:
<dependency> <groupId>com.sap.xs2.security</groupId> <artifactId>java-container-security-api</artifactId> <version>0.26.4</version> </dependency> <dependency> <groupId>com.sap.xs2.security</groupId> <artifactId>java-container-security</artifactId> <version>0.26.4</version> </dependency>
- Run
Maven update
for the project - Check the build path for the Java file to see if multiple libraries are used
Error
The import javax.servlet can’t be resolved [duplicate]
Resolution
You need to add the Servlet API to your classpath. In Tomcat 6.0, this is in a JAR called servlet-api.jar in Tomcat’s lib folder. You can either add a reference to that JAR to the project’s classpath, or put a copy of the JAR in your Eclipse project and add it to the classpath from there.
Reference
https://stackoverflow.com/questions/4119448/the-import-javax-servlet-cant-be-resolved
Error:
Unable to extract request URI: URI must contain a host
http://<virtual_host>:80/sap/opu/odata/sap/<odata_service>//$metadata
Resolution:
Update the SCC (SAP Cloud Connector) and SCP destination to make sure underscore is not used in the hostname
How to change the font size in Eclipse editor
Windows -> Preferences -> General -> Appearance -> Color and Fonts -> Basic -> Text Font -> Edit -> Apply
How to search for a string in a project in Eclipse
Ctrl + H
How to upload a project over 20M to SCP CF environment
Use Eclipse Cloud Foundry plugin