I am working on a project where I need to install the Spring Boot application Pet Clinic onto an Ubuntu 22 server using SSM Documents. I have attached the Systems Manager Run Document. The error below comes from the command sudo journalctl -u spring-petclinic.service. I tried giving any and all access, running as root, and it still isn't working.
Any idea on how to get this application to stay running?
May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Failed with result 'exit-code'.May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Scheduled restart job, restart counter is at 3.May 17 21:52:36 ip-10-0-4-141 systemd[1]: Stopped Spring PetClinic Application.May 17 21:52:36 ip-10-0-4-141 systemd[1]: Started Spring PetClinic Application.May 17 21:52:36 ip-10-0-4-141 java[7076]: Error: Unable to access jarfile /clinic/spring-petclinic/target/*.jarMay 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Main process exited, code=exited, status=1/FAILUREMay 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Failed with result 'exit-code'.May 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Scheduled restart job, restart counter is at 4.May 17 21:52:36 ip-10-0-4-141 systemd[1]: Stopped Spring PetClinic Application.May 17 21:52:36 ip-10-0-4-141 systemd[1]: Started Spring PetClinic Application.May 17 21:52:36 ip-10-0-4-141 java[7077]: Error: Unable to access jarfile /clinic/spring-petclinic/target/*.jarMay 17 21:52:36 ip-10-0-4-141 systemd[1]: spring-petclinic.service: Main process exited, code=exited, status=1/FA
---schemaVersion: '2.2'description: Install Java 17 and run the Spring PetClinic applicationparameters: {}mainSteps:- name: InstallJava17 action: aws:runShellScript inputs: runCommand: - | #!/bin/bash # Check if Java is installed if java -version > /dev/null 2>&1; then echo "Java is installed. No need to restart" else echo "Java is not installed. Restarting after install...." # Update package lists sudo apt-get update # Install OpenJDK 17 sudo apt-get install -y openjdk-17-jdk # Verify Java installation java -version exit 194 fi- name: DownloadApplication action: aws:runShellScript inputs: runCommand: - | #!/bin/bash # clean the environment file cat /dev/null > /etc/environment # set the full path echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:\$JAVA_HOME/bin\"" | sudo tee -a /etc/environment # grab the java home and set it in the environment JAVA_HOME=$(sudo update-alternatives --config java | grep -o -E '/usr/lib/jvm/[a-zA-Z0-9-]+') echo "JAVA_HOME=\"$JAVA_HOME\"" | sudo tee -a /etc/environment # update the variables source /etc/environment echo "whoami?" sudo whoami # Create and move into new folder sudo mkdir /clinic cd /clinic # Download the repository echo "# Download the repository" sudo git clone https://github.com/spring-projects/spring-petclinic.git # Move into the folder echo "# Move into the folder" cd spring-petclinic # Start the Maven build echo "# Start the Maven build" ./mvnw package- name: CreateSystemdService action: aws:runShellScript inputs: runCommand: - | #!/bin/bash # clean the environment file cat /dev/null > /etc/environment # set the full path echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:\$JAVA_HOME/bin\"" | sudo tee -a /etc/environment # grab the java home and set it in the environment JAVA_HOME=$(sudo update-alternatives --config java | grep -o -E '/usr/lib/jvm/[a-zA-Z0-9-]+') echo "JAVA_HOME=\"$JAVA_HOME\"" | sudo tee -a /etc/environment # update the variables source /etc/environment # Create systemd service unit echo "# Create systemd service unit" sudo tee /etc/systemd/system/spring-petclinic.service <<EOF [Unit] Description=Spring PetClinic Application After=network.target echo "THIS IS THE PATH" echo $PATH echo "THIS IS THE JAVA_HOME" echo $JAVA_HOME [Service] ExecStart=/usr/lib/jvm/java-17-openjdk-amd64/bin/java -jar /clinic/spring-petclinic/target/*.jar Restart=always User=root [Install] WantedBy=multi-user.target EOF echo "whoami?" sudo whoami # Reload systemd and start the service echo "# Reload systemd and start the service" echo "whoami?" sudo whoami echo "daemon is reloading" sudo systemctl daemon-reload echo "whoami?" sudo whoami echo "enabling spring-petclinic" sudo systemctl enable spring-petclinic echo "whoami?" sudo whoami echo "starting spring-petclinic" sudo systemctl start spring-petclinic