What product/components do you use and which version/fix level?
Cumulocity sdk
Are you using a free trial or a product with a customer license?
customer license
What are trying to achieve? Please describe in detail.
I am trying to compile one of the softwareag’s project that accesses InventoryApi, MeasurementApi. the GIT project is cumulocity-microservice-templates / basic But when I use one of the projects ‘basic’ under that am getting the following error while running. I need help to make it running and see the MeasurementApi accesing the measurements and create measurements also.
Error while running the application.is below
APPLICATION FAILED TO START
Description:
Parameter 0 of constructor in com.c8y.ms.templates.basic.service.DeviceService required a bean of type ‘com.cumulocity.sdk.client.inventory.InventoryApi’ that could not be found.
Action:
Consider defining a bean of type ‘com.cumulocity.sdk.client.inventory.InventoryApi’ in your configuration.
Do you get any error messages? Please provide a full error message screenshot and log file.
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2022-06-28 11:12:25.687 ERROR 2640 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Parameter 0 of constructor in com.c8y.ms.templates.basic.service.DeviceService required a bean of type ‘com.cumulocity.sdk.client.inventory.InventoryApi’ that could not be found.
Action:
Consider defining a bean of type ‘com.cumulocity.sdk.client.inventory.InventoryApi’ in your configuration.
i tested the basic template in the main branch. It was working for me. Could you please tell me how you started the .jar file, i mean the java -jar … command. Did you really use the cumulocity-microservice-templates-basic-0.0.1-SNAPSHOT.jar ? The exceptions shows that the cumulocity SDK classes are not in the class path. I could maybe imagin that you started: cumulocity-microservice-templates-basic-0.0.1-SNAPSHOT.jar.original
Hi Alexander,
Thanks for replying. I am compiling it using mvn clean install and running it using mvn spring-boot:run by adding a server port in the application.properties file. I am trying to access the end point in my local.
I have taken only the basic project out of the parent project cumulocity-microservice-templates and trying to compile and run it as i said above.
Could you tell me how did you start the application?
Are you able to access the end points defined in DeviceController and MeasurmentController in that case?
when i run mvn clean install its a succes, when i use mvn spring-boot:run it throws the error that i have given in my question initially.
I took out the “basic” project alone from the main project. So I had to make the following changes in pom.xml and application-dev.properties files. I have not done any other changes.
I have given and asked at some points in the properties file what needs to be filled. Kindly check below.
Trying to run mvn clean install - its buiding well. When I give mvn spring-boot:run it throws the error I have pasted at the last below.
Commented out the plugin section that creates the image. So I thought to run it in the local port 8082 as given in the properties file below.
application-dev.properties file changes
#Do not edit, version properties are set at build time
c8y.version=@c8y.version@
microservice.version=@project.version@
server.port=8082
#Cumulocity configuration for running localy and connecting to cumulocity
application.name=templates-basic
C8Y.bootstrap.register=true
C8Y.bootstrap.tenant= ??? what to be given for this
C8Y.baseURL=https://dev.iot.solenis.com
C8Y.bootstrap.user=
C8Y.bootstrap.password=
C8Y.microservice.isolation=MULTI_TENANT
Error when the project is run with mvn spring-boot:run
[INFO] — spring-boot-maven-plugin:2.7.0:run (default-cli) @ cumulocity-microservice-templates —
[INFO] Attaching agents:
Exception in thread “main” java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.context.logging.LoggingApplicationListener
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:449)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:431)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:424)
at org.springframework.boot.SpringApplication.(SpringApplication.java:268)
at org.springframework.boot.SpringApplication.(SpringApplication.java:246)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
at com.c8y.ms.templates.basic.App.main(App.java:11)
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/GenericApplicationListener
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:442)
… 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.event.GenericApplicationListener
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
… 20 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.458 s
[INFO] Finished at: 2022-06-28T17:56:48+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.7.0:run (default-cli) on project cumulocity-microservice-templates: Application finished with exit code: 1 → [Help 1]
[ERROR]
Hey Sethu,
you need to set all missing properties in the properties file (C8Y.bootstrap.tenant, C8Y.bootstrap.user, C8Y.bootstrap.password) Tenant is an id of your tenant, you can find it in the Admin App by clicking on you email in the right upper corner. To get you bootstrap credentials, please refer to the documentation → Microservice SDK for Java - Cumulocity IoT Guides
You would need to either deploy your microservice or create an application entry before.
Best,
Nick
Hi Alex,
I made only the minor change in the MeasurementController - commented out //@RequestMapping(path = “/measurements”)
I followed the ReadMe in the GIT and I am able to build and run the basic application now. But I am trying to call the end points from post man as below. Kindly help me on how to call the end points locally.
2022-06-29 09:41:02.429 INFO 25048 — [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x000xf70x010x000x000xf30x030x03P0x9d0xd50xb3l0xf20xce0xe90xcc0x950xc00xd20xb3gT0x110xd00x960xf50x100x970x0d0x970x070x9cp0x910x1160x090xc00x0e ]. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:419) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:271) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.63.jar!/:na]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]