I have this java file, it has to be executed using the following command otherwise it defaults to ipv6 and effectively useless for my use-case
-jar Djava.net.preferIPv4Stack=true EdOwl-Springboot.jar
I tried following this guide: https://computingforgeeks.com/how-to-run-java-jar-application-with-systemd-on-linux/
However using this shows:
root@edowl:~# systemctl status EdOwl-Springboot.service
● EdOwl-Springboot.service - EdowlSpringboot
Loaded: loaded (/etc/systemd/system/EdOwl-Springboot.service; disabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Tue 2022-02-22 11:28:26 UTC; 10s ago
Main PID: 186854 (code=exited, status=203/EXEC)
Tasks: 0 (limit: 614)
Memory: 0B
CGroup: /system.slice/EdOwl-Springboot.service
Feb 22 11:28:36 edowl.online systemd[1]: EdOwl-Springboot.service: Scheduled restart job, restart counter is at 125919.
Feb 22 11:28:36 edowl.online systemd[1]: Stopped EdowlSpringboot.
Feb 22 11:28:36 edowl.online systemd[1]: Started EdowlSpringboot.
Feb 22 11:28:36 edowl.online systemd[186888]: EdOwl-Springboot.service: Failed to execute command: No such file or directory
Feb 22 11:28:36 edowl.online systemd[186888]: EdOwl-Springboot.service: Failed at step EXEC spawning /bin/java: No such file or directory
Feb 22 11:28:36 edowl.online systemd[1]: EdOwl-Springboot.service: Main process exited, code=exited, status=203/EXEC
Feb 22 11:28:36 edowl.online systemd[1]: EdOwl-Springboot.service: Failed with result 'exit-code'.
the service file is as follows:
[Unit]
Description=EdowlSpringboot
[Service]
WorkingDirectory=/home
ExecStart=/bin/java -Xms128m -Xmx256m -jar Djava.net.preferIPv4Stack=true EdOwl-Springboot.jar
Type=simple
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
The file is located in the /home
dir
I am certain it is the exec start line that is messing this up, is it necessary to state: /bin/java -Xms128m -Xmx256m
or am I messing up something else here?
Suggestions are welcome cheers
CodePudding user response:
The JVM argument java.net.preferIPv4Stack
should be prefixed with -D
instead you have D
Change the command to /bin/java -Xms128m -Xmx256m -jar -Djava.net.preferIPv4Stack=true EdOwl-Springboot.jar