Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: java.lang.NoClassDefFoundError: org/apache/hc/client5/http/ssl/TlsSocketStrategy #747

Open
appDeveloper888 opened this issue Mar 10, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@appDeveloper888
Copy link

appDeveloper888 commented Mar 10, 2025

Describe the Bug

Hi,

we are java application in BTP Cloud Foundry.
I am using CLOUD SDK 5.17.0 to call IBP (same as S/4 HANA Cloud).
But I got the following error:
java.lang.NoClassDefFoundError: org/apache/hc/client5/http/ssl/TlsSocketStrategy

Best regards

Ying

ClassNotFoundException TlsSocketStrategy org.apache.cxf.interceptor.Fault: org/apache/hc/client5/http/ssl/TlsSocketStrategy at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:200) at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:103) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:265) at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:233) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:207) at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:159) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:224) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:312) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:217) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:279) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:195) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140) at com.sap.cloud.sdk.cloudplatform.servletjakarta.RequestAccessorFilter.lambda$doFilter$0(RequestAccessorFilter.java:56) at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor.lambda$execute$1(ThreadContextExecutor.java:260) at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor.call(ThreadContextExecutor.java:293) at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor.execute(ThreadContextExecutor.java:259) at com.sap.cloud.sdk.cloudplatform.servletjakarta.RequestAccessorFilter.doFilter(RequestAccessorFilter.java:56) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:598) at com.sap.xs.security.container.XSSecurityAuthenticator.invoke(XSSecurityAuthenticator.java:58) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) at com.sap.xs.java.valves.ErrorReportValve.invoke(ErrorReportValve.java:68) at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:268) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at com.sap.xs.jdbc.datasource.valve.JDBCValve.invoke(JDBCValve.java:62) at com.sap.xs.java.diagnostics.DiagnosticsValve.invoke(DiagnosticsValve.java:51) at com.sap.xs.security.TenantIdValve.invoke(TenantIdValve.java:33) at com.sap.xs.security.UserInfoValve.invoke(UserInfoValve.java:18) at com.sap.xs.logging.catalina.RuntimeInfoValve.invoke(RuntimeInfoValve.java:42) at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:731) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:397) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:905) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: java.lang.NoClassDefFoundError: org/apache/hc/client5/http/ssl/TlsSocketStrategy at com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder.(ApacheHttpClient5FactoryBuilder.java:18) at com.sap.grc.iag.cfjobs.util.IAGJobHttpRequest.getDataWithSDK(IAGJobHttpRequest.java:187) at com.sap.grc.iag.cfjobs.util.IAGServiceCall.callWithSDK(IAGServiceCall.java:247) at com.sap.grc.iag.cfjobs.util.IAGServiceCall.callService(IAGServiceCall.java:87) at com.sap.grc.iag.s4cloud.PrivilegeSyncCloudS4.getBusinessRoleList(PrivilegeSyncCloudS4.java:626) at com.sap.grc.iag.s4cloud.PrivilegeSyncCloudS4.businessRoleSync(PrivilegeSyncCloudS4.java:476) at com.sap.grc.iag.s4cloud.PrivilegeSyncCloudS4.privilegeSync(PrivilegeSyncCloudS4.java:447) at com.sap.grc.iag.s4cloud.PrivilegeSyncCloudS4.call(PrivilegeSyncCloudS4.java:278) at com.sap.grc.iag.jobs.RepoSyncJob.s4cSyncJob(RepoSyncJob.java:213) at com.sap.grc.iag.jobs.RepoSyncJob.runRepoSyncJob(RepoSyncJob.java:73) at com.sap.grc.iag.jobs.service.JobExecutionService.lambda$static$0(JobExecutionService.java:34) at com.sap.grc.iag.jobs.service.JobExecutionService.callJobImpl(JobExecutionService.java:135) at com.sap.grc.iag.jobs.service.JobExecutionService.startJob(JobExecutionService.java:113) at com.sap.grc.iag.jobs.service.JobExecutionService.executeJob(JobExecutionService.java:75) at com.sap.grc.iag.jobs.BGSchedulerJobs.runJob(BGSchedulerJobs.java:95) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:569) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ... 51 more Caused by: java.lang.ClassNotFoundException: org.apache.hc.client5.http.ssl.TlsSocketStrategy at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1374) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1183) ... 72 more

Steps to Reproduce

I can show you in a meeting

Expected Behavior

No exception should occur when we call S/4 HANA Cloud using Cloud SDK

Screenshots

No response

Used Versions

  • Java and Maven version via mvn --version:
    Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
    Maven home: C:\Users\I802528\maven\apache-maven-3.9.5-bin\apache-maven-3.9.5
    Java version: 17.0.14, vendor: SAP SE, runtime: C:\Program Files\SapMachine\JDK\17
    Default locale: en_US, platform encoding: Cp1252
    OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

  • SAP Cloud SDK version: .5.17.0

  • Spring Boot or CAP version: plain java

  • Dependency tree via `mvn dependency:tree`
           <dependency>
            <groupId>com.sap.cloud.sdk</groupId>
            <artifactId>sdk-bom</artifactId>
            <version>5.17.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    

Code Examples

public class IAGHttpRequestCommand {
	
	private final String destinationName;
    
    private final ClassicHttpRequest request;
    
    private final HttpClientContext httpContext;

    private ResilienceConfiguration resilienceConfig;
    
    private ApacheHttpClient5Factory customFactory;
    
    private HttpDestination httpDestination;
 
    private DestinationOptions options;
    

    /**
     * Use Cloud SDK to call Http Request using the BTP destination and service url
     *
     * @return IAGResponse an object with type IAGResponse which contains the status
     *         code and response from http call
     * @throws IagException
     * @throws IOException 
     */
    public IAGResponse execute() throws IagException, IOException {

        IAGResponse iagResponse = new IAGResponse();
    	String url = "";
		try {
			url = request.getUri().toString();
		} catch (URISyntaxException e) {
			log.error("IAGHttpRequestCommand=>execute, Error while getting URL from request", e);
			throw new IagException("Error while getting URL from request", e);
		}
		
		if (StringUtils.isBlank(this.destinationName)) {
			log.error("IAGHttpRequestCommand=>execute, destination Name is null or blank, please provide a valid destination name");
			throw new IagException("destination Name is null or blank, please provide a valid destination name");
		}
		    	
        if (this.options == null) {
            this.options = DestinationOptions
                .builder()
                .augmentBuilder(
                        DestinationServiceOptionsAugmenter
                                .augmenter()
                                .retrievalStrategy(DestinationServiceRetrievalStrategy.ONLY_SUBSCRIBER))
                .augmentBuilder(
                        DestinationServiceOptionsAugmenter
                                .augmenter()
                                .tokenExchangeStrategy(DestinationServiceTokenExchangeStrategy.LOOKUP_THEN_EXCHANGE))
                .build();
        }
        

	    this.httpDestination = new IAGSdkDestination().getHttpDestination(destinationName, this.options);
		
		
        if (this.customFactory == null) {
            this.customFactory = new ApacheHttpClient5FactoryBuilder()
                .timeout(Duration.ofMinutes(30L))
                .maxConnectionsTotal(100)
                .maxConnectionsPerRoute(20)
                .build();
        }
        
        HttpClient destinationClient = this.customFactory.createHttpClient(httpDestination);
        
        HttpClientResponseHandler<IAGResponse> responseHandler = new HttpClientResponseHandler<IAGResponse>() {
   
              @Override
              public IAGResponse handleResponse(final ClassicHttpResponse response) throws IOException, ParseException {
                  int status = response.getCode();
  
                  IAGResponse iagResp = new IAGResponse();
                  iagResp.setStatusCode(status);
                  
                  if (response.getEntity() != null) {                	                
                	  iagResp.setResponse(org.apache.hc.core5.http.io.entity.EntityUtils.toString(response.getEntity()));
                  } else {
                	  // handle null HTTP response entity
                	  iagResp.setResponse("Response entity is null");
                  }
  
                  return iagResp;
  
              }
        };

        if (TestUtils.isRunningUnderJUnit()) {
        	
			iagResponse = new IAGResponse(200, "{\"message\": \"success\"}");
			return iagResponse;
        }
        
                
        try {

            iagResponse = (this.httpContext == null) ? destinationClient.execute(this.request, responseHandler)
                    : destinationClient.execute(this.request, this.httpContext, responseHandler);
            
            log.trace(
                    "IAGHttpRequestCommand=>execute, after httpClient execute call for url:{}, status code: {} , response: {}",
                     url, iagResponse.getStatusCode(), iagResponse.getResponse());

        } catch (IOException e) {

            log.error("",
                    "IAGHttpRequestCommand=>execute, cloudSdkCall failed with status code: {} and response : {} for url: {}",
                    iagResponse.getStatusCode(), iagResponse.getResponse(), url, e);

            throw new IagException("SDK call failed, url: " + url + ", code: " + iagResponse.getStatusCode()
                    + ", response: " + iagResponse.getResponse(), e);
        }

        return iagResponse;
    }
    
}

Stack Trace

No response

Log File

Log file ...

Affected Development Phase

Release

Impact

Blocked

Timeline

No response

@appDeveloper888 appDeveloper888 added the bug Something isn't working label Mar 10, 2025
@CharlesDuboisSAP
Copy link
Contributor

You are most likely overriding the httpclient5 version to something older than 5.4 or the httpcore5 to something older than 5.3.
Please remove them and the sdk-bom will set versions automatically.
see

Best, Charles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants