Deploying war file on Vesta CP - java

I am doing this for the first time. I have a VPS server with Vesta CP installed on it. I did the following -
Created a new Web Domain.
It automatically created entries in DNS
I setup FTP user for myself.
I am able to connect to ftp using Fileszilla.
In filezilla, I can see public_html folder (but NOT .htaccess)
Created WAR file from eclipse for my application.
Uploaded my war inside public_html.
tried - http://myserver_ip/MenuBook/HomePageServlet - in browser. It
said 404 Page not found. (MenuBook is the ContextRoot of my web
application)
Can someone please explain what else do I have to do to make this work. I read that you have to modify .htaccess file too, here - https://documentation.cpanel.net/display/CKB/How+to+Deploy+Java+Applications
But I can not see any .htaccess file through ftp.
Please help. Any help will be greatly appreciated.

you must install web server that support java servlets like tomcat or glassfish ... vestacp by default has no just webservers you must install it your self
you can check this link it may help
https://forum.vestacp.com/viewtopic.php?f=11&t=6977

Related

Can not find WAR file path after deployment using tomcat 8 manager

I have been testing my tomcat 8 setup on debian 9. Everything seems fine until I try to deploy a helloServlet WAR file through tomcat 8 manager. I created the very simple example program following the instruction here.
I use tomcat manager to upload the HellowServlet.war from my working directory. Then I can access it though http://localhost:8080/HelloServlet/sayhello
The program works just fine. However, no matter how I search (/etc/tomecat8 /usr/share/tomcat*), I just can not find the war file or any components inside of it. I really want to know the exact location of my application file. Anyone may tell me where the application files are stored by the tomcat 8 mananger?
More update:
I just tried to upload the same war file again, and I got following message from tomcat
FAIL - War file "HelloServlet.war" already exists on server
That means the war file is sitting somewhere on the server, but the path is unknown to me.
Found it.... it's inside /var/lib/tomcat8/webapps
However, I can not find any configuration file in tomcat 8 describing that it uses /var/lib/tomcat8 as one of its working directory.

Read files from another pc Using JAVA and apache tomcat

File[] files = new File("\\172.22.1.77\FolderName").listFiles();
I'm trying to read some files from another IP on my network from shared folder 'FolderName'.
It works locally from eclipse.
But when it deployed on apache tomcat, it doesn't work.
Any help about this ?
Check if the user under which Tomcat is running has permissions to access the folder

how to read geolitecity file path from linux server?

My development environment is windows, using JSP,Apache server 5.5. I developed an application with the help of geolitecity provided by MaxMind. I have uploaded geolitecity.dat into my server in the same folder of my website(I dont know its the correct procedure, I am doing it first time).And I used
String systemPath=new java.io.File(".").getCanonicalPath();
to get the current directory path, so that I can read from it. But I am not getting the full path. am only getting upto tomcat5.5.3\bin. Is it possible to read the file with this path? I dont have much knowledge in linux.
In Servlet/JSP:
String path = getServletContext().getRealPath("/yourfilename.txt");
This will give you complete path of given file name.
Note: It will work when you will deploy it in tomcat and run from out side eclipse. As eclipse has its own internal structure when it deploy the web application [if not changed].

How to deploy a Java Web Application (.war) on tomcat?

I have a .war file of a Java Web Application. Now I want to upload it to my ftp server so that I can execute it.
What steps I should perform to run it?
The context path of the webapp is /mywebapp
Edit
Actually, my ftp server name is ftp://bilgin.ath.cx/ and I have uploaded my TestWebApp.war file to this dir: ftp://bilgin.ath.cx/web
Then what should be the URL to access the index.html page of the webapplication
#2 Edit
Tomcat is listening on 8082
Apache access Tomcat with jk connector.
As others pointed out, the most straightforward way to deploy a WAR is to copy it to the webapps of the Tomcat install. Another option would be to use the manager application if it is installed (this is not always the case), if it's properly configured (i.e. if you have the credentials of a user assigned to the appropriate group) and if it you can access it over an insecure network like Internet (but this is very unlikely and you didn't mention any VPN access). So this leaves you with the webappdirectory.
Now, if Tomcat is installed and running on bilgin.ath.cx (as this is the machine where you uploaded the files), I noticed that Apache is listening to port 80 on that machien so I would bet that Tomcat is not directly exposed and that requests have to go through Apache. In that case, I think that deploying a new webapp and making it visible to the Internet will involve the edit of Apache configuration files (mod_jk?, mod_proxy?). You should either give us more details or discuss this with your hosting provider.
Update: As expected, the bilgin.ath.cx is using Apache Tomcat + Apache HTTPD + mod_jk. The configuration usually involves two files: the worker.properties file to configure the workers and the httpd.conf for Apache. Now, without seeing the current configuration, it's not easy to give a definitive answer but, basically, you may have to add a JkMount directive in Apache httpd.conf for your new webapp1. Refer to the mod_jk documentation, it has a simple configuration example. Note that modifying httpd.conf will require access to (obviously) and proper rights and that you'll have to restart Apache after the modifications.
1 I don't think you'll need to define a new worker if you are deploying to an already used Tomcat instance, especially if this sounds like Chinese for you :)
copy the .war file in the webapps folder
upload the file using the manager application - http://host:port/manager. You will have to setup some users beforehand.
(not recommended, but working) - manually extract the .war file as a .zip archive and place the extracted files in webapps/webappname
Sometimes administrators configure tomcat so that war files are deployed outside the tomcat folder. Even in that case:
After you have it deployed (check the /logs dir for any problems), it should be accessible via: http://host:port/yourwebappname/. So in your case, one of those:
http://bilgin.ath.cx/TestWebApp/
http://bilgin.ath.cx:8080/TestWebApp/
If you don't manage by doing the above and googling - turn to your support. There might be an alternative port, or there might be something wrong with the application (and therefore in the logs)
The tomcat manual says:
Copy the web application archive file into directory $CATALINA_HOME/webapps/. When Tomcat is started, it will automatically expand the web application archive file into its unpacked form, and execute the application that way.
Note that you can deploy remotely using HTTP.
http://localhost:8080/manager/deploy
Upload the web application archive
(WAR) file that is specified as the
request data in this HTTP PUT request,
install it into the appBase directory
of our corresponding virtual host, and
start it using the war file name
without the .war extension as the
path. The application can later be
undeployed (and the corresponding
application directory removed) by use
of the /undeploy. To deploy the ROOT
web application (the application with
a context path of "/"), name the war
ROOT.war.
and if you're using Ant you can do this using Tomcat Ant tasks (perhaps following a successful build).
To determine which path you then hit on your browser, you need to know the port Tomcat is running on, the context and your servlet path. See here for more details.
Log in :URL = "localhost:8080/"
Enter username and pass word
Click Manager App
Scroll Down and find "WAR file to deploy"
Chose file and click deploy
Done
Go to Webapp folder of you Apache tomcat you will see a folder name matching with your war file name.
Type link in your url address bar:: localhost:8080/HelloWorld/HelloWorld.html and press enter
Done

Deploying Web Apps as war Files

I'm having some trouble uploading and getting my web app on the net with my chosen host. I built a war file in Net Beans and asked my host to deploy it for me. This worked fine but to access it I had to point my browser to:
www.myDomain.co.uk/explodedWar
What of course I wanted was to be able to access it just by pointing my browser at:
www.myDomain.co.uk
The war file contains the whole app, index.html, images, classes etc.
Is this possible or am I missing something ? ?
You can call the war ROOT.war but the best way is to change the context path in the servlet container. To do this in Tomcat you would add the following to your server.xml:
<context path="" docBase="explodedWar" debug="0"/>
If you name your war ROOT.war (in Tomcat) it should do what you want.
This is a question you need to ask your host about since they are deploying it for you.

Categories