Skip to Content
Technical Articles

Tomcat8 and JDK8 in Neo SAP Cloud Platform

  1. Introduction:

This article will be helpful for who upgrade the run time from JEE6 to Tomcat 8 and who develop the application using JDK8 and deploy in Tomcat 8. Especially this is prepared for Neo cloud platform.  This may be applicable to upgrade from any version of JEE run time to any version of Tomcat. This article is derived based on the run time exceptions and errors, we faced.  Article will help the problem solvers, solution providers, debuggers and testers. By reading this article you can save lot of time when you migrate from JDK7 to JDK8. this  may help for who is upgrading any lower version of Java to any higher version.

As many of you know, Some of the classes which are there in JEE libraries those are not there in Tomcat, I handled and resolved those class not found exceptions. I found or came to know the alternatives during the run time.

During the integration or communication between  the cloud deployed applications, cloud to external, external to cloud and cloud to on premise, you will face the following problems or errors, I have described those problems and solutions together here.

 

  1. Class Not Found Exception:

These classes HttpDestination and DestinationFactory are not available in Tomcat8.

These above classes should be replaced by the ConnectivityConfiguration and DestinationConfiguration.

JEE6 or JEE7

{

com.sap.core.connectivity.api.http.HttpDestination;

com.sap.core.connectivity.api.DestinationFactory;

}

Tomcat8

{

com.sap.core.connectivity.api.configuration.ConnectivityConfiguration;

com.sap.core.connectivity.api.configuration.DestinationConfiguration;

}

 Using these replacement classes still you can access the destination configuration details from the cockpit.

  1. Http Connection:

Http client cannot be used for making http connection in Tomcat8, the alternate for HttpClient is HttpUrlConnection.

JEE6 or JEE7

{

httpClient = destination.createHttpClient();

}

Tomcat8

{

urlConnection = (HttpURLConnection) url.openConnection();

}

 

  1. Cloud to Cloud:

It is possible to have App to App SSO authentication when you want to communicate from one application from another application. So, the user propagation (Principle propagation) can be done easily.

{

Context ctx = new InitialContext();

AuthenticationHeaderProvider authHeaderProvider = (AuthenticationHeaderProvider) ctx.lookup(AUTH_PROVODER_JNDI_LOOKUP);

AuthenticationHeaderProvider authorization = authHeaderProvider (urlString);

AuthenticationHeader appToAppSSOHeader = authorization.getAppToAppSSOHeader(urlString);

AuthenticationHeader principle = authorization.getPrincipalPropagationHeader();

}

This explicit principle propagation and app to app sso are not required in case of JEE6 runtime.

 

  1. 403 Forbidden Issue:

When you want to send data using POST API from one application to another, CSRF is required this is applicable for both JEE and Tomcat. But only with CSRF header, 403 will not be resolved in case of Tomcat. You have set the cookie property also in connection object.

{

writeCon.setRequestProperty(HTTP_COOKIE, session);

}

The cookies can be got from response header of get API when you get CSRF,

{

List<String> session = readCon.getHeaderFields().get(HTTP_SET_COOKIE);

}

The below link will be helpful to resolve 403 Error.

https://help.sap.com/saphelp_nw73ehp1/helpdata/en/79/108d3aacaf4209b91b760280f82e13/frameset.htm

 

  1. Cloud to On-premise:

When you make a call from cloud to On-Premise system, you should add a proxy when you open a connection in case of Tomcat.

{

urlConnection = (HttpURLConnection) url. openConnection(proxy)

The proxy should be taken from platform itself as below.

private static Proxy getProxy(String proxyType) {

String proxyHost = null;

int proxyPort;

if (ON_PREMISE_PROXY.equals(proxyType)) {

// Get proxy for on-premise destinations

proxyHost = System.getenv(“HC_OP_HTTP_PROXY_HOST”);

proxyPort = Integer.parseInt(System.getenv(“HC_OP_HTTP_PROXY_PORT”));

} else {

// Get proxy for internet destinations

proxyHost = System.getProperty(“http.proxyHost”);

proxyPort = Integer.parseInt(System.getProperty(“http.proxyPort”));

}

return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));

};}

More detail can be found here,

https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/474eae1b69c9434b9dce0314b8d2b6b1.html

 

  1. SSLHandshakeException:

When you try to connect from Cloud to On-Premise system, you will get SSLHandshakeException.

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

To resolve this issue, the URL’s protocol should be changed from Https to Http. The url with Https protocol will work in case of JEE runtime, but https protocol throws SSLHandshakeException in case of Tomcat.

  1. 503 Service Un available:

To resolve 503- Service un available, you should add a property(SAP-Connectivity-SCC-Location_ID) cloud connector’s location id

{

urlConnection.setRequestProperty(“SAP-Connectivity-SCC-Location_ID”, “Cloud_Connector_Location_Id”);

}

“Service un available “ may occur due to the client (cloud application) not able to find exact target cloud connector, if the sub account has many cloud connectors.

 

  1. 400 Bad Request:

TO resolve  400 error, you should add the  account name as below,

{

urlConnection.setRequestProperty(“SAP-Connectivity-ConsumerAccount”, System.getenv(“HC_ACCOUNT”));

}

This is to make a confirmation to target system who make request, from which account.

  1. References:

 Consume Back-End Systems (Java Web or Java EE 6 Web Profile)

https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/e76f9e75bb571014a7218bcd30a8771b.html

Consume Back-End Systems (Java Web Tomcat 7)

https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/474eae1b69c9434b9dce0314b8d2b6b1.html

 

XSRF Protection for REST Services

https://help.sap.com/saphelp_nw73ehp1/helpdata/en/79/108d3aacaf4209b91b760280f82e13/frameset.htm

HTTP Proxy for On-Premise Connectivity

https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/d872cfb4801c4b54896816df4b75c75d.html

Platform Authorization Management API

https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/dbea343ebe184c26b6067daaabaa9ac6.html

11.Conclusion:

This is purely technical article nothing to talk about any functional areas. this is article i made to help  the colleagues who ever is upgrading or migrating from JDK7 to JDK8 and JEE server to Tomcat 8 This article i have created for helping others, no need to spend much time to debug. This will help Developers, Testers and Architects. Here I have talked about the run time problems of connecting from cloud based application to external, external to cloud application, cloud to On-premise. I described to resolve various run time exceptions like SSL handshake and HTTP error codes 400, 403 and 503.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.