0

I'm getting issues in running hello world project when I created it from below command:

mvn archetype:generate -DarchetypeGroupId=com.sap.cloud.s4hana.archetypes -DarchetypeArtifactId=scp-cf-spring -DarchetypeVersion=LATEST

The project gets created fine but when I'm running the application I get an error in creating beans, the error looks something like this:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor': Cannot create inner bean '(inner bean)#630d4350' of type [com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor] while setting bean property 'listener'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor] for bean with name '(inner bean)#630d4350' defined in URL [jar:file:/Users/setup/.m2/repository/com/sap/cloud/s4hana/cloudplatform/caching/2.4.2-SNAPSHOT/caching-2.4.2-SNAPSHOT.jar!/com/sap/cloud/sdk/cloudplatform/cache/CacheMonitor.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: com/sap/cloud/sdk/cloudplatform/monitoring/JmxMonitor . . .

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor] for bean with name '(inner bean)#630d4350' defined in URL [jar:file:/Users/setup/.m2/repository/com/sap/cloud/s4hana/cloudplatform/caching/2.4.2-SNAPSHOT/caching-2.4.2-SNAPSHOT.jar!/com/sap/cloud/sdk/cloudplatform/cache/CacheMonitor.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: com/sap/cloud/sdk/cloudplatform/monitoring/JmxMonitor . . .

Caused by: java.lang.ClassNotFoundException: com.sap.cloud.sdk.cloudplatform.monitoring.JmxMonitor

Please let me know if I should furnish more details.

Nick_Kh
  • 5,089
  • 2
  • 10
  • 16
Rahul Pandey
  • 141
  • 1
  • 11
  • Can provide some more details on what you have done? If I run your command the project is generated just fine (as you have written) and runs locally as well as on CloudFoundry without a problem. A first glance at the stacktrace, however, leads me to the assumption, that you are missing the `com.sap.cloud.s4hana.cloudplatform:core` dependency on your classpath. Can you verify that via `mvn dependency:tree`? – Christoph Schubert Sep 05 '18 at 14:01
  • @ChristophSchubert Result of my dependency tree contains: com.sap.cloud.s4hana.cloudplatform:core-scp-cf:jar:2.4.2-SNAPSHOT:compile, shouldn't this be sufficient ? The -DarchetypeVersion=LATEST generated my project with 2.4.2-SNAPSHOT – Rahul Pandey Sep 06 '18 at 03:51
  • I generated project with version: 2.3.1, it is working fine now.: mvn archetype:generate -DarchetypeGroupId=com.sap.cloud.s4hana.archetypes -DarchetypeArtifactId=scp-cf-spring -DarchetypeVersion=2.3.1, Seems there is some problem with snapshots – Rahul Pandey Sep 06 '18 at 05:44
  • The SNAPSHOT versions are our current develop builds, so they can be somewhat unstable. However, I would like to understand your issue to prevent it from finding its way into the 2.4.2 release. Can you please add the output of the command `mvn dependency:tree -pl application -Dincludes=com.sap.cloud.s4hana.cloudplatform:core` to your question? – Christoph Schubert Sep 06 '18 at 07:10
  • Result: Scanning for projects... [INFO] Building mkt-agency-app - Application 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ mkt-agency-app-application --- [INFO] com.sap.cec.mkt:mkt-agency-app-application:jar:0.0.1-SNAPSHOT [INFO] \- com.sap.cloud.s4hana.frameworks:cxf:jar:2.4.2-SNAPSHOT:compile [INFO] \- com.sap.cloud.s4hana.cloudplatform:core:jar:2.4.2-SNAPSHOT:compile – Rahul Pandey Sep 06 '18 at 13:34
  • Okay, so the dependency is on your classpath. Then I have no further idea, what the actual problem is. In combination with your other question I would just assume some issue in your maven cache. To mark this question as "answered" can you please provide an answer containing your fix/downgrade to the actual releases version? – Christoph Schubert Sep 06 '18 at 14:05
  • Sure, the fix is: I generated project with version: 2.3.1, it is working fine now.: mvn archetype:generate -DarchetypeGroupId=com.sap.cloud.s4hana.archetypes -DarchetypeArtifactId=scp-cf-spring -DarchetypeVersion=2.3.1 – Rahul Pandey Sep 06 '18 at 14:56
  • Okay, little misunderstanding here: I meant that you provide this as a real answer to your own question above so that you can accept it and this question is officially flagged as answered. That way you will also get some Stackoverflow reputation :-) – Christoph Schubert Sep 07 '18 at 07:09

1 Answers1

1

The fix is: I generated project with version: 2.3.1, it is working fine now.:

mvn archetype:generate -DarchetypeGroupId=com.sap.cloud.s4hana.archetypes -DarchetypeArtifactId=scp-cf-spring -DarchetypeVersion=2.3.1
Rahul Pandey
  • 141
  • 1
  • 11