cancel
Showing results for 
Search instead for 
Did you mean: 

NoClassDefFoundError: Could not initialize class com.sap.cloud.security.token.Token

gp5
Newcomer
0 Kudos
186

We have developed a Java-servlet based extension application for SAP SuccessFactors. Our deployment package includes both the Java application and the Approuter application, which customers deploy through the SAP BTP Cloud Foundry environment. We use Approuter for authentication, and once a request is successfully authenticated, it is forwarded to our Java application.

Although the application generally operates smoothly, one of our customers occasionally experiences the issue described below (which may occur once a month or even more frequently). This problem is resolved when the application is manually restarted.

Could you please assist us in identifying the root cause of this issue?

  1. When an application URL (via approuter) is accessed, the application logs the following error in BTP: 

 

java.lang.NoClassDefFoundError: Could not initialize class com.sap.cloud.security.token.Token

2024-09-06T05:01:16.834+0000 [APP/PROC/WEB/0] STDOUT {"msg":"Error processing request","level":"ERROR","written_ts":"1725598876833000000","logger":"org.apache.coyote.http11.Http11Processor","exception_type":"java.lang.NoClassDefFoundError","written_at":"2024-09-06T05:01:16.833Z","thread":"http-nio-0.0.0.0-8080-exec-5","type":"log","exception_message":"Could not initialize class com.sap.cloud.security.token.Token","stacktrace":["java.lang.NoClassDefFoundError: Could not initialize class com.sap.cloud.security.token.Token","\tat com.sap.xs.security.UserInfoFactory.createXsuaaToken(UserInfoFactory.java:105)","\tat com.sap.xs.security.UserInfoFactory.checkAndSetXsuaaToken(UserInfoFactory.java:46)","\tat com.sap.xs.security.UserInfoValve.invoke(UserInfoValve.java:17)","\tat com.sap.xs.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:43)","\tat com.sap.xs.logging.catalina.RuntimeInfoValve.invoke(RuntimeInfoValve.java:42)","\tat org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:765)","\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)","\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)","\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)","\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)","\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1790)","\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)","\tat org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)","\tat org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)","\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)","\tat java.lang.Thread.run(Thread.java:838)","Caused by: java.lang.ExceptionInInitializerError: Exception java.util.ServiceConfigurationError: com.sap.cloud.security.token.TokenFactory: Provider com.sap.cloud.security.servlet.HybridTokenFactory not a subtype [in thread \"http-nio-0.0.0.0-8080-exec-1\"]","\tat java.util.ServiceLoader.fail(ServiceLoader.java:239)","\tat java.util.ServiceLoader.access$300(ServiceLoader.java:185)","\tat java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)","\tat java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)","\tat java.util.ServiceLoader$1.next(ServiceLoader.java:480)","\tat java.lang.Iterable.forEach(Iterable.java:74)","\tat com.sap.cloud.security.token.Token$1.<init>(Token.java:31)","\tat com.sap.cloud.security.token.Token.<clinit>(Token.java:29)","\tat com.sap.cloud.connectivity.apiext.cloud.destinationservice.DestinationServiceClient.getDestinationServiceAccessToken(DestinationServiceClient.java:77)","\tat com.sap.cloud.connectivity.apiext.cloud.destinationservice.DestinationServiceClient.getAuthorizationToken(DestinationServiceClient.java:121)","\tat com.sap.cloud.connectivity.apiext.cloud.destinationservice.DestinationServiceClient.findDestination(DestinationServiceClient.java:114)","\tat com.sap.cloud.connectivity.apiext.cloud.configuration.datasource.CloudDataSourceImpl.getDestinationConfiguration(CloudDataSourceImpl.java:41)","\tat com.sap.core.connectivity.apiext.impl.cache.AbstractDataSourceCache$1.compute(AbstractDataSourceCache.java:88)","\tat com.sap.core.connectivity.apiext.impl.cache.AbstractDataSourceCache$1.compute(AbstractDataSourceCache.java:72)","\tat com.sap.core.connectivity.apiext.impl.cache.util.Memoizer$1.call(Memoizer.java:109)","\tat com.sap.core.connectivity.apiext.impl.cache.util.Memoizer$1.call(Memoizer.java:105)","\tat com.sap.core.connectivity.apiext.impl.cache.CircuitBreakerFutureExecutor.execute(CircuitBreakerFutureExecutor.java:44)","\tat com.sap.core.connectivity.apiext.impl.cache.AbstractDataSourceCache$DatasourceMemoizer$2.call(AbstractDataSourceCache.java:297)","\tat com.sap.core.connectivity.apiext.impl.cache.AbstractDataSourceCache$DatasourceMemoizer$2.call(AbstractDataSourceCache.java:294)","\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)","\tat com.sap.core.connectivity.apiext.impl.cache.util.PeriodicFutureExecutor.runTask(PeriodicFutureExecutor.java:60)","\tat com.sap.core.connectivity.apiext.impl.cache.util.PeriodicFutureExecutor.execute(PeriodicFutureExecutor.java:49)","\tat com.sap.core.connectivity.apiext.impl.cache.util.Memoizer.compute(Memoizer.java:79)","\tat com.sap.core.connectivity.apiext.impl.cache.AbstractDataSourceCache.computeFromMemoizer(AbstractDataSourceCache.java:160)","\tat com.sap.core.connectivity.apiext.impl.cache.AbstractDataSourceCache.getDestinationConfiguration(AbstractDataSourceCache.java:230)","\tat com.sap.core.connectivity.apiext.impl.cache.AbstractDataSourceCache.getDestinationConfiguration(AbstractDataSourceCache.java:220)","\tat com.sap.core.connectivity.apiext.impl.configuration.reader.DataSourceConfigurationReader.readDestinationConfiguration(DataSourceConfigurationReader.java:22)","\tat com.sap.core.connectivity.apiext.impl.configuration.provider.AbstractConfigurationProvider$1.load(AbstractConfigurationProvider.java:58)","\tat com.sap.core.connectivity.apiext.impl.configuration.provider.AbstractConfigurationProvider$1.load(AbstractConfigurationProvider.java:54)","\tat com.sap.core.connectivity.apiext.impl.configuration.provider.AbstractConfigurationProvider.provide(AbstractConfigurationProvider.java:179)","\tat com.sap.core.connectivity.apiext.impl.configuration.provider.AbstractConfigurationProvider.provideDestinationConfiguration(AbstractConfigurationProvider.java:67)","\tat com.sap.core.connectivity.apiext.impl.configuration.provider.AbstractConfigurationProvider.getDestinationConfiguration(AbstractConfigurationProvider.java:54)","\tat com.sap.core.connectivity.apiext.impl.configuration.AbstractConnectivityConfiguration.getConfiguration(AbstractConnectivityConfiguration.java:60)","\tat com.sap.core.connectivity.apiext.impl.configuration.AbstractConnectivityConfiguration.getConfiguration(AbstractConnectivityConfiguration.java:46)"

 

 

  • When the business users try to access the application URL(via approuter), they receive the following error, even though both the main application and approuter are in running state in SAP BTP.

gp5_0-1726059267771.png

manifest.yml :

 

---
# Extension application
- name: sf-extension 
  memory: 900M
  timeout: 300
  routes:
    - route: sfextension.cfapps.us10-001.hana.ondemand.com
  path: SfExtension.war
  buildpacks:
    - sap_java_buildpack
  env:
    TARGET_RUNTIME: tomcat
    USE_CONNECTIVITY_APIEXT: true
    APP_ROUTER_URL: https://websfextension.cfapps.us10-001.hana.ondemand.com
    SET_LOGGING_LEVEL: "{ROOT: DEBUG}"
  services:
   - xsuaa
   - destination
   - sap_hcmcloud_core_odata
   - connectivity
# Application Router 
- name: approuter-sf-extension
  path: approuter
  buildpacks: 
    - nodejs_buildpack
  memory: 124M
  routes:
    - route: websfextension.cfapps.us10-001.hana.ondemand.com
  services:
    - xsuaa
  env:
    destinations: >
      [
        {"name":"sap_hcmcloud_core_odata",
         "url":"https://sfextension.cfapps.us10-001.hana.ondemand.com",
         "forwardAuthToken": true}
      ]

 

 

 mvn dependency:tree
 
[INFO] +- commons-validator:commons-validator:jar:1.7:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- com.google.code.gson:gson:jar:2.9.0:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.1:compile
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] +- com.sun.jersey:jersey-client:jar:1.19.4:compile
[INFO] +- com.sun.jersey:jersey-core:jar:1.19.4:compile
[INFO] +- com.sun.jersey.contribs:jersey-multipart:jar:1.19.4:compile
[INFO] |  \- org.jvnet.mimepull:mimepull:jar:1.9.3:compile
[INFO] +- commons-codec:commons-codec:jar:1.13:compile
[INFO] +- commons-io:commons-io:jar:2.11.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.14.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.1:compile
[INFO] +- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.14.1:compile
[INFO] +- joda-time:joda-time:jar:2.10.3:compile
[INFO] |  \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] +- com.github.librepdf:openpdf:jar:1.3.28:compile
[INFO] +- com.sap.cloud.db.jdbc:ngdbc:jar:2.13.9:compile
[INFO] +- com.sap.cloud.security:java-security:jar:2.13.4:compile
[INFO] |  +- com.sap.cloud.security:java-api:jar:2.13.4:compile
[INFO] |  +- com.sap.cloud.security:env:jar:2.13.4:compile
[INFO] |  |  +- com.sap.cloud.environment.servicebinding:java-sap-vcap-services:jar:0.10.1:compile
[INFO] |  |  |  \- com.sap.cloud.environment.servicebinding.api:java-core-api:jar:0.10.1:compile
[INFO] |  |  +- com.sap.cloud.environment.servicebinding:java-sap-service-operator:jar:0.10.1:compile
[INFO] |  |  +- com.sap.cloud.environment.servicebinding.api:java-consumption-api:jar:0.10.1:compile
[INFO] |  |  \- com.sap.cloud.environment.servicebinding.api:java-access-api:jar:0.10.1:compile
[INFO] |  \- com.sap.cloud.security.xsuaa:token-client:jar:2.13.4:compile
[INFO] |     +- com.sap.cloud.security.xsuaa:api:jar:2.13.4:compile
[INFO] |     \- com.github.ben-manes.caffeine:caffeine:jar:2.9.3:compile
[INFO] |        +- org.checkerframework:checker-qual:jar:3.19.0:compile
[INFO] |        \- com.google.errorprone:error_prone_annotations:jar:2.10.0:compile
[INFO] +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] +- com.sun.xml.bind:jaxb-core:jar:2.3.0:compile
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.3.2:compile
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
[INFO] |  +- org.junit.platform:junit-platform-engine:jar:1.8.2:test
[INFO] |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  |  \- org.junit.platform:junit-platform-commons:jar:1.8.2:test
[INFO] |  +- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
[INFO] |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] +- org.mockito:mockito-core:jar:4.6.1:test
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.12.10:test
[INFO] |  +- net.bytebuddy:byte-buddy-agent:jar:1.12.10:test
[INFO] |  \- org.objenesis:objenesis:jar:3.2:test
[INFO] +- org.mockito:mockito-inline:jar:4.6.1:test
[INFO] +- org.mockito:mockito-junit-jupiter:jar:4.6.1:test
[INFO] +- com.h2database:h2:jar:2.1.214:test
[INFO] +- javax.websocket:javax.websocket-api:jar:1.1:provided
[INFO] +- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.3.1:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.7.28:provided
[INFO] +- com.sap.xs:java-js-client:jar:1.7.2:provided
[INFO] |  +- org.slf4j:slf4j-simple:jar:1.7.36:provided
[INFO] |  \- org.apache.commons:commons-lang3:jar:3.12.0:provided
[INFO] \- com.sap.cloud:neo-java-web-api:jar:3.154.5:provided
[INFO]    +- org.apache.chemistry.opencmis:chemistry-opencmis-commons-api:jar:1.0.0:provided
[INFO]    +- javax.el:javax.el-api:jar:3.0.0:provided
[INFO]    +- org.apache.chemistry.opencmis:chemistry-opencmis-client-api:jar:1.0.0:provided
[INFO]    +- javax.mail:javax.mail-api:jar:1.5.5:provided
[INFO]    \- org.glassfish:javax.annotation:jar:3.1-b41:provided
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
 

 

 

 

 

 

 

Accepted Solutions (0)

Answers (0)