I have a single jar server app (simple web portal) built with Spring Boot. I run it:
java -jar myapp.jar
Locally, the jar file is under my Eclipse project folder. Now it's ready to be deployed on a Linux server as a service. What folder should I create on the server to put the jar file? In that folder (working directory), I will be putting the application.yaml file plus some other config files. The service will run as root.
Create a directory under either /opt or /usr and have your jar run from there.
If your app creates one log file, configure it for /var/log. If it's going to write a few create a directory /var/log/<your app>.
Related
I have a server.jar file which I want to deploy on Heroku. When I run heroku deploy:jar server.jar --app myapp, heroku deploy only server.jar file, but I also want to deploy server.properties file. How can I do it?
You can package the property files inside the Jar file (if you use Maven is straightforward).
If you need to update these values at runtime (when deploying on Heroku) you need to look at Config Vars
I have developed Azure pipeline, its ok sending the jar file to my App service, but that jar file is not running. Even though I initiate it manually doing SSH and java -jar abcjar it shows application hosted at 8080 but its not showing.
Steps already taken
add plugin in pom.xml"
added web.config by FTP on site www root
"nohup java -jar abc.jar &"
Tried downloading the jar file via FTP and run it, its working fine.
I got a success by referring to the tutorial: Deploy a Spring Boot JAR file app to Azure App Service with Maven and Azure on Linux
Rename jar file to app.jar
Add an application setting:
I am linux admin and i want to automate the process of java web application deployment process in my client location. And actually they are using svn tool for version control.
So my question is if they commit the code into subversion repository automatically create a war file through bash script and move that war file into tomcat for automated deployment....
This is my thought.. can u guys suggest me about war file creation remain process i can build through bash
Thank u in advance
To create war file, you need to use jar tool of JDK. You need to use -c switch of jar, to create the war file.
Go inside the project directory of your project (outside the WEB-INF), then write the following command:
jar -cvf projectname.war *
Here, -c is used to create file, -v to generate the verbose output and -f to specify the arhive file name.
The * (asterisk) symbol signifies that all the files of this directory (including sub directory).
There are multiple ways to create WAR file
Using ANT/Maven or many times framework also provides command e.g. Play Framework.
You basically need to go to the SVN checkout project folder.
if you have ANT or Maven project than follow the steps :
How to create a WAR file using the commandline?
How to create war files
else for other Java based project :
To create war file, you need to use jar tool of JDK. You need to use -c switch of jar, to create the war file.
Go inside the project directory of your project (outside the WEB-INF), then write the following command:
jar -cvf projectname.war *
https://www.javatpoint.com/war-file
You can then copy the newly created WAR file to Tomcat webapps folder using linux command
SCP or CP.
I currently have a working servlet created in Eclipse. When running it from the Tomcat plugin, everything works, and my app shows up at localhost:8080/project_name/. However, when I package the project into a .war file and place it in the /webapps directory of Tomcat and start the server, the servlet cannot be accessed. In Terminal, I can see Tomcat loading my project, and a temporary folder of the unarchived project is also created in /webapps. However, I simply cannot access my servlet.
Note:
I'm using Tomcat 7 and I don't have a web.xml file in my project.
How are you creating the war file? Check if your war files contain jar files under WEB-INF/lib folder and if the class files are not missing. You can easily verify it under tomcat/webapps/[project name] folder.
As per the Google tutorial, I have developed the basic StockWatcher application, that makes an RPC call to the server, which sends some data, which is displayed on the client.
I now want to deploy it in Tomcat, such that if call something like localhost/StockWatcher, I should get the same experience as when running the app from GWT in development mode.
How do I do this? There is a similar topic here, but I couldn't much understand it. If I only copy the compiled war folder, what happens to the GreetingServiceImpl class which handles the RPC? And how do I do the mapping such that localhost/StockWatcher maps to localhost:8080 (something like Mod_Rewrite)?
Steps to deploy war on TOMCAT
1)Compile you gwt web application
2)Copy the war file
3)Add all libraries(jar files) in lib folder of war file
4)Rename your war as "myapp"
5)create a .war file with that "myapp" folder
6)start tomcat with catalina.bat run.
For step5 (generating .war file ):Preparing .war file from command line
Normally if you deploy well your war directory and you are able to start tomcat you have done everything. If you access your page using this url : localhost:8080/StockWatcher gwt will know that it must use that url as a baseURL for all gwt/rpc requests.
To generate the war using Eclipse : right click on the project -> export -> war. You will have the war exported with all the dependencies inside. just unzip it in the ROOT directory