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

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.

Related

Is there a Node.js documentation explaining how to setup an application environment?

I'm looking for a documentation which describes the standard way of setting up a Node.js server. I'm wondering whether there is such a thing, actually.
I'm writing a Linux (Ubuntu) server and administrators of a standard server would find it normal to find the settings of the application under:
# Admin editable settings
/etc/<app-name>/<app-name>.conf
# Read-only files used by the server
/usr/lib/<app-name>/...
# Read-Write files used by the server
/var/lib/<app-name>/...
The <app-name>.conf file could be used to change the other paths.
Does the default Linux organization sound completely out of wack for a Node.js application?
IMPORTANT: I'm not in any way interested about how to read the .conf or what format it should be in. That part already works exactly as I want it to work. I'm only interested in where those files are expected to be installed when someone installs your Node.js service.

Changing and creating files in .NET Core folder

for example, there is an application written using dot net core 2.1
Published under the IIS (Windows Server 2016). At the root of the application (near to the binaries (.dll)) random files are being created and modified. Will this affect the performance of the application? Will it make a difference if these files are created in a subdirectory next to the binaries?
If we exclude IIS and host under Kestrel, will it affect somehow?
As far as I remember, when hosting applications, written on a .NET fullframework, under IIS, and modifying any file (for example, a text file) in the BIN directory resulted in restarting the web application.
I do not know what files are being created and modified i would separate them form the app files for security reasons to say the least. Having said that to answer your question.
It should not affect the performance unless the volume of operations is so large that it will use up all iops on the drive or the pc/ram of the machine.
Kestrel will not be affected unless you try to modify files that kestrel uses for the app in some way and if you use dotnet watch run it will try to recompile them and run in the host if not it will ignore their existence until the host is restarted.
IIS should ignore them as well but i do not know what will happen if you have those files in bin and try to restart the host. i have tried changing and adding a file and did not restart. Maybe there is something in IIS settings but since i have not setup our IIS my answer is lacking in that regard.

Alternative for file access in windows share files

We have an application (built on .NET), which will need to read some mass storage files.
So we deploy the application in the Web server, and put the data in the data server. Then the application in the web server will access the files through windows share files.(Both the Web server and data Server use the Windows Server OS.
Now, we tried to change from windows to linux, then how about the file access?
The Samba suite provides windows file server functionality for unix systems.
Also you might like to look at NFS.
Even OCFS2 might be an alternative.

file creation in linux

I have created an application in which the android mobile takes picture and uploads it to a server. The server accepts the image, stores in local directory and updates the path to the database. Everything works fine on my localhost (Windows) but when i deploy the war file it is not creating the file. The problem is my localhost is on windows but the main server(ISP) is on Linux. Both my localhost and main server (ISP) are using glassfish. On the main server (ISP) I am logging through admin and then deploying the war file.
This might be your problem.
Where do you store your file in the server. In windows you might be giving the path as
D://images/dir1/......
In linux this path is not valid. It should look something like
/home/tomcat/images/repo/...........
Please post the code where you mention the location of the directory in which you store the images.

How to deploy a WAR file on Linux machine

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.

Resources