1

I am trying to get a java app(server) to start as a service using systemd on my Centos 7 but it always fails.

this is my push.service

[Unit]
Description=b4xpush server
After=syslog.target
After=network.target

[Service]
ExecStart=/usr/java/jdk1.8.0_45/bin/java -jar /home/mike/push/PushServer.jar
Type=simple
Restart=on-failure

[Install]
WantedBy=multi-user.target

after creating the file, I start by using

sudo systemctl start Push.service

but in vain...

The java app will run fine if I run it manually:

/usr/java/jdk1.8.0_45/bin/java -jar /home/mike/push/PushServer.jar

or

java -jar /home/mike/push/PushServer.jar

How can I get it running? The ultimate goal is to get it start when the server boots.

Could it be a permission error? When I try to create this I'm logged in as mike and I have "sudo" rights. The app (jarfile) is located in my home-folder as you can see in above service-file.

I have tried everything I can think of but I cannot resolve it and get it to work. Any ideas?

Edit: Added log file using status:

[mike@vps ~]$ sudo systemctl status Push.service -l
Push.service - b4xpush server
   Loaded: loaded (/etc/systemd/system/Push.service; disabled)
   Active: failed (Result: start-limit) since Thu 2015-11-12 16:20:52 CET; 1min 25s ago
  Process: 3651 ExecStart=/usr/java/jdk1.8.0_45/bin/java -jar /home/mike/push/PushServer.jar (code=exited, status=1/FAILURE)
 Main PID: 3651 (code=exited, status=1/FAILURE)

Nov 12 16:20:52 vps.server.com java[3651]: at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
Nov 12 16:20:52 vps.server.com java[3651]: at b4j.example.main.main(main.java:29)
Nov 12 16:20:52 vps.server.com systemd[1]: Push.service: main process exited, code=exited, status=1/FAILURE
Nov 12 16:20:52 vps.server.com systemd[1]: Unit Push.service entered failed state.
Nov 12 16:20:52 vps.server.com systemd[1]: Push.service holdoff time over, scheduling restart.
Nov 12 16:20:52 vps.server.com systemd[1]: Stopping b4xpush server...
Nov 12 16:20:52 vps.server.com systemd[1]: Starting b4xpush server...
Nov 12 16:20:52 vps.server.com systemd[1]: Push.service start request repeated too quickly, refusing to start.
Nov 12 16:20:52 vps.server.com systemd[1]: Failed to start b4xpush server.
Nov 12 16:20:52 vps.server.com systemd[1]: Unit Push.service entered failed state.
[mike@vps ~]$
  • 1
    Can you post the log of the failure please ? That would help understanding why this fails – Pierre-Alain TORET Nov 12 '15 at 15:18
  • OK, log file from status command added. It works on its owns but not when trying to start it as a service – moster67 Nov 12 '15 at 15:30
  • You need to look at the complete log, not just the last few lines. – Michael Hampton Nov 12 '15 at 15:31
  • Is it when the server starts ? or is it when you manually start the service ? It could be starting too soon and the network is not ready yet. – Pierre-Alain TORET Nov 12 '15 at 15:32
  • @pat: when I manually start the service. First I'd like to see it working by starting it manually and once it is fine, I would try it on reboot – moster67 Nov 12 '15 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.