How to deploy a WAR file on Linux machine - linux

I have a Linux Machine. Apache server is running and I need to deploy my project which is a .war file developed on Windows machine.
Can someone give me bit idea how to do that?

if you have FTP or SCP access to the directories where Tomcat is installed, you should be able to simply copy the generated WAR file to the tomcat/webapps directory. Tomcat will automatically deploy the war for you.
When redeploying, I find it safest to delete the original .WAR file in Tomcat, and tomcat will automatically destory the exploded directory for you. When that's done, copy up the .WAR file.
Finally, make sure you copy the .WAR file "all at once". If you have a slow upload, Tomcat will try and deploy the .WAR file even though it has not completely been uploaded yet. This will lead to a partial or unsuccessful deployment. It's best if you upload to a neutral directory (home directory, temp, whichever), and then either rename (using mv) the .WAR into tomcat, or simply copy it there using the local file systems copy command. Much faster than the upload. Safest way is to mv the file from the same filesystem.
All of this assumes you do not have any of the manager or admin ports open for Tomcat, as it provides mechanisms to remotely deploy applications directly.
But, in truth, simply removing the old app and slipping in the new app works simply and well for many applications.

Related

Accidentally deleted tomcat `webapps` folder

I have accidentally deleted the webapps folder in tomcat. I had 2 web applications there deployed as .war files and the default tomcat folder, "Root", "manager", "host-manager", "examples" and "docs".
Since I am on cloud amazon EC2 instance (ubuntu) and I have no use of tomcat manager, can I simply create a new directory manually called webapps and copy and paste the .war files of my projects?
Will this work or is this subjected to break something at some point?
Absolutely yes, your apps will be automatically deployed again after some seconds.
Moreover, you can download those Root, manager, host-manager, examples and docs folders from the tomcat distribution, and copy them into your webapps directory. The manager and host-manager apps will restart automatically.
Since the configuration to access manager and host-manager is inside conf/tomcat-users.xml, it has not been deleted. So the apps will work like previously, without any change.

Copy file from inside a .war, after deploying to liferay

I want to copy a configuration file from inside the .war file which is being deployed to a specific folder. The reason is that I want to pick it up and process it afterwards, and I might have multiple files, depending on the number of archives deployed on the server. Is there a way to trigger this action, after Liferay picks up the .war file? If yes, any suggestions how?
p.s. I have 0 experience with Liferay

Deploy JSF-Maven application from Eclipse directly to tomcat

Well, i have doubts about best practice to do a deploy correctly. So, lets go.
I have a project JSF with Maven in my local machine in ECLIPSE IDE. In other side (my server online) i have a Tomcat Server (version 6) + SVN Server working normally. The communication from my Eclipse with SVN Repository works fine. My doubt is about putting WAR file from my eclipse workspace to tomcat webapp folder, so i have some solutions to do this:
A) This is the most simple form but i don't know if this correct (best practice): Make a Maven Build (in ECLIPSE) and i'll have a WAR file. Copy the WAR file manually to tomcat webapp folder.
B) Make a "svn checkout" in my "SERVER ONLINE" (where is locate my svn server) and after i can make "mvn tomcat:deploy" to generate WAR file, and copy to tomcat webapp folder.
C) I think this form is more correct but i don't know how can i do: From my ECLIPSE IDE directly deploy (create WAR file) in TOMCAT Remote Server (webapp remote folder).
D) Open "http://XXX.XXX.XXX.XXX:8080/manager/html" and put manually the WAR file.
Well, this is the first time i'm doing this, and i need know what is the most used form.
I and heard most people deploy by A C D way.
You can do it manually without Eclipse see here

How to deploy a data file on tomcat web server in linux debian OS

I have a web application developed using JSP and Servlet. This web application is deployed on server having Debian Linux as OS and The Tomcat version is 5.5.31. As this applications required some data files, These data files will be get created automatically when setting are done using a standalone java application. This application is deployed on another machine. This setup is done. As I dont know much about Debian Linux and where my application is goes on it so I have some doubts in deployment of these autimatically generated data files which are as follows
As I made the .war file of my web application and deployed it using Tomcat Manager. so I dont know where exactly my application goes. I dont know the exact path. How do I find it?
Is it possible to create FTP for this web application which is deployed on Debian Linux server? I think that if creating FTP is possible then I will directly connect to FTP using my Stand alone Java program and will easily do the creation of the file and other file and directory manipulation.
If you've deployed a war, the application isn't anywhere on the filesystem as such. Most servers will unpack the war somewhere, but you shouldn’t rely on where that is.
I can think of several options:
getServletContext().getAttribute("javax.servlet.context.tempdir") to get the application's temp directory, then inform you external program of this location and place the file somewhere in there in a know location.
Arrange for a "know location" outside of the application, such as /tmp/somewhere or /var/cache/your-app/somewhere to place such files. (Note: /tmp is usually cleaned on startup of a linux machine)
As for getting the file onto the server from a remote machine: You could get your client to upload the file directly to your webapp (something like Apache HTTPClient will help you there), which means that you could do without the "know location" above. If you want to do this outside of the application though, I'd avoid FTP (due to security). Instead, I'd go with scp (secure copy).
Edit: Reading between the lines a little, you mention "setting" in the data file. If this is a configuration file which is not changed once the app is running, you may find it more convenient to have a "deploy" step on your server which simply takes the settings file and adds it to the war before deploying it. This is easy enough with "ant war" for example. You could then access the file using getClass().getResourceStream(..) or such.

Cruisecontrol, deployment, folder permissions

We're using cruisecontrol.net, it builds the version, creates a zip file, then 15 min later, unzips the file on the Integration server. But when the folder gets to the integration server, often, the security permission on one of the folders is totally hosed. The Domain admin and folder owner can't even open the folder in explorer. We reboot and the folder permissions are good we can delete the folder and redeploy the zip file and it's okay.
Does anyone have any idea what or how the folder permissions are getting so messed up?
Any tools to use to diagnose/watch what exactly is messing it up?
Have you tried using psexec from system internals to upzip to file on the remote machine rather than the build machine?
Also, it seems to me that rather than unzipping the zip just copy the stuff directly to the remote server. I'm not seeing the reason to zip it and then just unzip it?

Resources