2

I created a runnable jar using spring-boot-maven-plugin. The jar can be run using jar -jar %FILENAME%.

But I'd like to install it as a windows service using procrun.

Problem: when I then start the app, I get the following output:

[2016-12-05 12:33:22] [info]  [ 7788] Starting service...
[2016-12-05 12:33:23] [error] [ 4856] FindClass de/app/MyApplication failed
[2016-12-05 12:33:23] [error] [ 7788] Failed to start Java
[2016-12-05 12:33:23] [error] [ 7788] ServiceStart returned 4
[2016-12-05 12:33:23] [info]  [ 7916] Run service finished.
[2016-12-05 12:33:23] [info]  [ 7916] Commons Daemon procrun finished

If I rename the file to *tar.gz I can see there is no directory "de/app/". But a BOOT-INF/classes/de/app directory.

The question is: why is the app startable by using java -jar, but not as the procrun service (which should basically do the same)?

Issam El-atif
  • 2,366
  • 2
  • 17
  • 22
membersound
  • 81,582
  • 193
  • 585
  • 1,120
  • 2
    Spring Boot has its own launcher, so no it is not doing the same as `procrun `. When using `java -jar` Spring boot has its own launcher and classpath mechanism to be able to cope with the file format. How to start a spring boot application as a windows service is (sparsely) documented in [the reference guide](http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html#deployment-windows). You should be using `winsw` instead of `procrun`. – M. Deinum Dec 05 '16 at 13:04

2 Answers2

2

Kind of late to the show, but in case anyone stumbles across this problem:

The fat jar files generated by spring contain wrapped dependencies. If you want to run them through procrun, you can do so by calling org.springframework.boot.loader.JarLauncher

So when creating your service, try this:

prunsrv //IS/Myservice --Classpath="C:\my-fat.jar" --StartClass="org.springframework.boot.loader.JarLauncher"

This is the equivalent of running java -jar my-fat.jar

Michael
  • 695
  • 2
  • 12
  • 36
0

Apparently, Spring Boot starting from 1.4.0.RELEASE has a changed fat jar packaging which is closer to WAR packaging.

Issue described here.

As a solution you can try to add a classifier to the maven execution like described here, or just change to an older version of Spring Boot.

Hope this helps!

Turbut Alin
  • 2,568
  • 1
  • 21
  • 30