# Jump-Start your next Cumulocity microservice project in java

**URL:** <https://community.cumulocity.com/t/jump-start-your-next-cumulocity-microservice-project-in-java/3976>\
**Category:** Knowledge Base\
**Tags:** cumulocity\
**Created:** [May 23, 2022, 12:57pm UTC](https://community.cumulocity.com/t/jump-start-your-next-cumulocity-microservice-project-in-java/3976 "2022-05-23T12:57:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Pester](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/alexander_pester/32/5725_2.png) [@Alexander\_Pester](https://community.cumulocity.com/u/Alexander_Pester)\
**Post date:** [May 23, 2022, 12:57pm UTC](https://community.cumulocity.com/t/jump-start-your-next-cumulocity-microservice-project-in-java/3976/1 "2022-05-23T12:57:42Z")

</div>

## Introduction

Setting up a microservice for Cumulocity using [Microservice SDK](https://cumulocity.com/guides/microservice-sdk/java/) project is easy.

However, a few manual steps must be taken before you have a successfully running microservice locally configured to your Cumulocity instance. To speed this process up, use a maven archetype instead: [cumulocity-microservice-archetype](https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype)

This open-source maven archetype helps you to setup your maven project in less than 5 minutes!!!

It is not just faster; it is also a good template which are based on best practices.

In this blog post I show you, step by step how to use this cumulocity-microservice-archetype to setup your first project “hello”.

## Pre-requisite

- Java installed \>= 11
- Maven installed \>= 3.6
- Cumulocity IoT Tenant \>= 1010.0.0
- Cumulocity IoT User Credentials (Base64 encoded)

## Steps to follow

**Step 1:** Go to [GitHub - Cumulocity-IoT/cumulocity-microservice-archetype: Maven archetype for cumulocity microservice. Developed by Global Competency Center IoT](https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype) and clone the repository

**Step 2:** Build and install the cumulocity-microservice-archetype in your local maven repository

```auto
$ cd cumulocity-microservice-archetype
$ mvn install

```

**Step 3:** Generate your project by using the archetype

Move to the location you would like to generate the project:

```auto
$ cd ..
$ cd workspace

```

Before you run the mvn archetyp:generate command you should know:

- Microservice name
- Cumulocity development environment URL:
- Cumulocity development environment User credentials in Base64

Your Base64 user credentials you can collect via Developer tools, Network tab. The request header contains the Authorization option.

> If you use [go-c8y-cli](https://goc8ycli.netlify.app/) you can use an easier way of using the archetype. Just use the environment variable which are set by that cli `C8Y_BASEURL` and `C8Y_HEADER_AUTHORIZATION`. set-session on your terminal and run following maven command **Example** : `$ mvn archetype:generate -DarchetypeGroupId=cumulocity.microservice -DarchetypeArtifactId=cumulocity-microservice-archetype -DinteractiveMode=false -DmicroserviceName=hello -DdevC8yBaseURL="$C8Y_BASEURL" -DdevC8yUserCredentialsBASE64="$C8Y_HEADER_AUTHORIZATION"`

If you have all the parameter, then you can run following script (replace Basic XXXXX with your Base64 credentials and [https://your.tenant.cumulocity.com](https://your.tenant.cumulocity.com) with your cumulocity instance)

```auto
$ mvn archetype:generate -DarchetypeGroupId=cumulocity.microservice -DarchetypeArtifactId=cumulocity-microservice-archetype -DinteractiveMode=false -DmicroserviceName=hello -DdevC8yBaseURL=https://your.tenant.cumulocity.com -DdevC8yUserCredentialsBASE64="Basic XXXXX"

```

If you run interactive mode you get for each parameter an input prompt. For more details look at [GitHub - Cumulocity-IoT/cumulocity-microservice-archetype: Maven archetype for cumulocity microservice. Developed by Global Competency Center IoT](https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype)

If maven tells you “BUILD SUCCESS”, you can continue with Step 4

**Step 4:** Run your fresh generated microservice the first time

```auto
$ cd cumulocity-microservice-hello
$ mvn clean install
$ cd target
$ java -jar cumulocity-microservice-hello-1.0.0-SNAPSHOT.jar

```

**Step 5:** Open the browser a check if microservice is running successfully

`http://localhost:8080/api/hello/devices`

The browser will open an user/password dialog. Insert you user in following way {tenant}/{user name}.

If this REST endpoint is returning an array of all devices. Well done, you have already setup your microservice project successfully!!

**Step 6:** Develop further and use some good examples

Now you can start developing your own features. The project contains a simple controller and service. These classes should be removed and are placeholders for your controllers and services.

If you have special nonfunctional requirements please check the microservice templates. They contain good examples how to solve common problems.

> **[GitHub - Cumulocity-IoT/cumulocity-microservice-templates: Collection of templates / examples to give the...](https://github.com/Cumulocity-IoT/cumulocity-microservice-templates)**
>
> Collection of templates / examples to give the developer a starting point how common features can be solved by using Cumulocity Microservice SDK for Java. Developed by Global Competency Center IoT

## Useful links | Relevant resources

[https://cumulocity.com/guides/microservice-sdk/java/](https://cumulocity.com/guides/microservice-sdk/java/)  
[https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype](https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype)  
[https://github.com/Cumulocity-IoT/cumulocity-microservice-templates](https://github.com/Cumulocity-IoT/cumulocity-microservice-templates)  
[https://maven.apache.org/guides/introduction/introduction-to-archetypes.html](https://maven.apache.org/guides/introduction/introduction-to-archetypes.html)

---

<div class="post-metadata">

**Author:** ![amsakan](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@amsakan](https://community.cumulocity.com/u/amsakan)\
**Post date:** [December 13, 2023, 5:02pm UTC](https://community.cumulocity.com/t/jump-start-your-next-cumulocity-microservice-project-in-java/3976/2 "2023-12-13T17:02:29Z")

</div>

When running the archetype and filling out all the information I get the following error:

[INFO] ------------------------------------------------------------------------  
[INFO] BUILD FAILURE  
[INFO] ------------------------------------------------------------------------  
[INFO] Total time: 3.471 s  
[INFO] Finished at: 2023-12-13T18:02:05+01:00  
[INFO] ------------------------------------------------------------------------  
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate (default-cli) on project standalone-pom: Text must not be null or empty → [Help 1]  
[ERROR]  
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.  
[ERROR] Re-run Maven using the -X switch to enable full debug logging.  
[ERROR]  
[ERROR] For more information about the errors and possible solutions, please read the following articles:  
[ERROR] [Help 1] [MojoFailureException - Apache Maven - Apache Software Foundation](http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException)

---

<div class="post-metadata">

**Author:** ![Alexander\_Pester](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/alexander_pester/32/5725_2.png) [@Alexander\_Pester](https://community.cumulocity.com/u/Alexander_Pester)\
**Post date:** [December 18, 2023, 7:47pm UTC](https://community.cumulocity.com/t/jump-start-your-next-cumulocity-microservice-project-in-java/3976/3 "2023-12-18T19:47:17Z")

</div>

Thank you for reporting that issue. I was so free to create an issue at github:

> <https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype/issues/16>
>
> \[INFO\] ------------------------------------------------------------------------
> …
> \[INFO\] BUILD FAILURE
> \[INFO\] ------------------------------------------------------------------------
> \[INFO\] Total time: 3.471 s
> \[INFO\] Finished at: 2023-12-13T18:02:05+01:00
> \[INFO\] ------------------------------------------------------------------------
> \[ERROR\] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate (default-cli) on project standalone-pom: Text must not be null or empty → \[Help 1\]
> \[ERROR\]
> \[ERROR\] To see the full stack trace of the errors, re-run Maven with the -e switch.
> \[ERROR\] Re-run Maven using the -X switch to enable full debug logging.
> \[ERROR\]
> \[ERROR\] For more information about the errors and possible solutions, please read the following articles:
> \[ERROR\] \[Help 1\] \[MojoFailureException - Apache Maven - Apache Software Foundation\](http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException)

I will investigate why this happend: Could you please tell me which java, maven version and sdk you are using?

  

* * *

Alexander Pester

[Software AG Professional Services](https://www.softwareag.com/en_corporate/resources/services/professional-services.html)

[![](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/c/3/c3a93a2618e4708f51be40fe2e142061f7c4edc7.jpeg)](https://www.softwareag.com/en_corporate/resources/services/fast-track-services.html)

---

<div class="post-metadata">

**Author:** ![Alexander\_Pester](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/alexander_pester/32/5725_2.png) [@Alexander\_Pester](https://community.cumulocity.com/u/Alexander_Pester)\
**Post date:** [December 20, 2023, 3:28pm UTC](https://community.cumulocity.com/t/jump-start-your-next-cumulocity-microservice-project-in-java/3976/4 "2023-12-20T15:28:39Z")

</div>

Issue is fixed [Build Failure: Text must not be null or empty · Issue #16 · Cumulocity-IoT/cumulocity-microservice-archetype · GitHub](https://github.com/Cumulocity-IoT/cumulocity-microservice-archetype/issues/16)
