# Building and deploying java app with balenaos

**URL:** <https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933>\
**Category:** openBalena\
**Tags:** raspberrypi3, java\
**Created:** [April 8, 2019, 8:32am UTC](https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933 "2019-04-08T08:32:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kameshs](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/kameshs/32/1743_2.png) [@kameshs](https://forums.balena.io/u/kameshs)\
**Post date:** [April 8, 2019, 8:32am UTC](https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933/1 "2019-04-08T08:32:34Z")

</div>

am trying to deploy a Java application to my local openbalena, but am getting the following error

```auto
 balena deploy blinker --source . --logs

[Info] Creating default composition with source: /Users/kameshs/MyLabs/iot/piker/led-blink
[Info] Building for armv7hf/raspberrypi3
[Build] Building services...
[Build] main Preparing...
[Build] Built 1 service in 0 seconds
[Error] Deploy failed
Resolution could not be performed

Additional information may be available in debug mode. Prefix the command
line with DEBUG=1, i.e.: DEBUG=1 balena ...
If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io

For bug reports or feature requests, have a look at the GitHub issues or
create a new one at: https://github.com/balena-io/balena-cli/issues/

```

Not sure why its not able do docker build of java project.

the dockerfile used is

```auto
# TODO pre install pi4j 
FROM balenalib/%%BALENA_MACHINE_NAME%%-fedora-openjdk:8-28-run

WORKDIR /usr/src/app

COPY ./target/led-blink-runner.jar /usr/src/app/led-blink-runner.jar

ENV INITSYSTEM=on

CMD ["java", "-jar","led-blink-runner.jar"]

```

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [April 9, 2019, 7:41am UTC](https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933/4 "2019-04-09T07:41:24Z")

</div>

Could you please try with `DEBUG=1` as the cli suggests:  
`DEBUG=1 balena deploy blinker --source . --logs`  
and paste the output here?

---

<div class="post-metadata">

**Author:** ![kameshs](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/kameshs/32/1743_2.png) [@kameshs](https://forums.balena.io/u/kameshs)\
**Post date:** [April 9, 2019, 8:05am UTC](https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933/5 "2019-04-09T08:05:03Z")

</div>

@zvin I was able to get past it with build and deploying to my device, on the way found potential issue on how balena cli handling builds [https://github.com/balena-io/balena-cli/issues/1157](https://github.com/balena-io/balena-cli/issues/1157)

Am still confused on how the resolution is done? The following files in root?

- package.json
- Dockerfile
- Dockerfile.template
- docker-compose.yml
- requirements.txt

Just my 2 cents  
For Java I would suggest doing a scan of pom.xml or build.gradle

---

<div class="post-metadata">

**Author:** ![shaunmulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shaunmulligan/32/34_2.png) [@shaunmulligan](https://forums.balena.io/u/shaunmulligan)\
**Post date:** [April 9, 2019, 6:37pm UTC](https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933/6 "2019-04-09T18:37:58Z")

</div>

@kameshs currently `balena deploy` and `balena push` only understand the following:

- package.json
- Dockerfile
- Dockerfile.template
- docker-compose.yml

In the future we might add more language packs to make java, python, rust, etc easier to get started, but currently one needs to handle this via any of the 4 above options.

---

<div class="post-metadata">

**Author:** ![kameshs](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/kameshs/32/1743_2.png) [@kameshs](https://forums.balena.io/u/kameshs)\
**Post date:** [April 12, 2019, 10:24am UTC](https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933/10 "2019-04-12T10:24:15Z")

</div>

Thanks @shaunmulligan i resorted to using Dockerfile and things works well.

---

<div class="post-metadata">

**Author:** ![shaunmulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shaunmulligan/32/34_2.png) [@shaunmulligan](https://forums.balena.io/u/shaunmulligan)\
**Post date:** [April 23, 2019, 5:25pm UTC](https://forums.balena.io/t/building-and-deploying-java-app-with-balenaos/5933/11 "2019-04-23T17:25:46Z")

</div>

Thats great to hear @kameshs, I also updated the documentation a bit on this, you can see it here now [https://www.balena.io/docs/learn/deploy/deployment/#project-structure](https://www.balena.io/docs/learn/deploy/deployment/#project-structure)
