How to deploy many applications on Tomcat 7 - java

I have a server where is running my web-application, located in the root folder (you can see it in the image, the path is /).
I reach that application by typing the IP and the Port (for example 111.222.333.444:1234).
Now I'm trying to deploy another web-application and reach it by typing 111.222.333.444:1234/prova/index.jsp (you can see it in the image, the path is /prova).
By using Tomcat Web Application Manager I uploaded a new war file called prova.war.
But, when I try to start it by clicking the start button, it doesn't start. In fact, when I click the start button, the Tomcat Web Application Manager I get the message:
FAIL - Application at context path /prova could not be started
.
If I use a ftp client, I can see that prova.war was correctly (I assume) unpacked.
Thank you.

Please check the log file. I.e you can check catalina.out file may be there are some issues while deploying the your new application (i.e prova)

Related

How to restart tomcat application when a file change?

I have an application represented by an exploded .war:
/webapps/myWebapp
Usually, when the .war is present, I do the following via command line:
touch /webapps/myWebapp.war
This changes the last modification date on the war, making the tomcat redeploy the application inside of its folder: the old folder is deleted and a new one is created again.
Unfortunately I don't have the .war, but only the application folder and, sometimes, I need to change some files inside of it and a restart is requested in order for the changes to take effect.
Is there a similar way to accomplish the same without restarting the whole tomcat server?
Alternatively I could do that via the manager console...the problem is that I want my user to be able to only restart that application, not every single application deployed.
Can you give me some hints/suggestions? Thanks
You may want to look at the property WatchedResource
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
WatchedResource - The auto deployer will monitor the specified static resource of the web application for updates, and will reload the web application if is is updated. The content of this element must be a string.
Just add paths of the files that you want to see the changes.

Starting .war file from another war in Tomcat 8

Is there a way to start/stop .war file from inside another .war?
I'm running SymmetricDS server using Tomcat 8 (it deploys it's own .war) and I need to start it, when a button is pressed and Stop likewise. Can I do that?
When a war file is "dropped" into Tomcat's webapp folder, by default Tomcat automatically deploys it and starts it. When source war file is deleted from the webapp folder, Tomcat automatically stops and undeploys the webapp.
So basically all you need to do is copy and delete the war file to/from the webapp folder to start/stop a webapplication.
Also (or if you can't do this) Tomcat has a built-in manager webapplication which is capable to deploy new applications (from war-files), or to stop and undeploy running web applications.
See Manager App HOW-TO for more details on this.
If you want to do this from your code, check out the ManagerServlet class. You can call it with simple URLs and parameters. The javadoc of the class contains example URLs what you can do with it. Here are 2 important operations specifically to your needs:
/start?path=/xxx - Start the web application attached to context path /xxx for this virtual host.
/stop?path=/xxx - Stop the web application attached to context path /xxx for this virtual host.

How to change path for web project in eclipse

I wrote the web application using Spring MVC. When I deploy the app to the server path is localhost:8080/projectName/. It is possible to remove projectName from path from eclipse? I found path in project properties but I cannot find the way how to change it.
I found that I have to change context root to : "/". I changed it but that has no effect.
Thank you for any help.
Regards,
Sebastian
I would break down your question into two parts :
A. Changes to the context root not taking any effect.
For changes to the context root to take effect, you must clean and republish you webapp on your server for the context root changes to get activated. To run "Clean" in context of the server from within eclipse,
Stop the Server
Window -> Show View -> Server -> Right click on your server configuration -> Clean. (Note: To "Clean" the server outside of eclipse, you need to go to the "webapps" directory of your server on your local filesystem and delete the .war file as well as the "project-name" folder which holds the exploded WAR file. )
Deploy your webapp to the server and restart the server.
B. Trying to run your webapp at the context root / - localhost:8080
From what it looks like, you are trying to run your web application at the "Root" of your application server. You haven't mentioned the application server that you are using, but let us for example assume that the server you are using is tomcat. For tomcat, to deploy an application which will run at localhost:8080/ you need to either deploy the exploded war under the "ROOT" directory at $CATALINA_HOME/webapps/ROOT , or name your war file to be root.war.
The $CATALINA_HOME/webapps/ROOT and $CATALINA_HOME/webapps/root.war are special keywords which tell tomcat to deploy the application at content root /.
If you are NOT using tomcat as your application server, then provide more details on the application server being used to see if I can help.

GlassFish Quandary

I am trying to install GlassFish (on a Mac) as directed by a book on Core JSF. When I go to
http://localhost:8080
I see the page as displayed in the book, with no problems. However, when I copy the login.war file to the directory specified in the book and try to go to the login page
http://localhost:8080/login
I simply see a 404 Error.
I /think/ I have copied the file correctly. What does this indicate? By virtue of the fact that I am able to see the page
http://localhost:8080
correctly does this mean that GlassFish has been appropriately installed? What does the 404 Error likely mean? Thanks. Conor.
The 404 error is the HTTP page not found error. This means, the page you are trying to access does not exist. I believe your application is not deployed on the server.
To deploy your application, go to server admin page localhost:4848 click on application from the navigation menu. From there click on Deploy and browse to the file location. You can also specify the context root where your application should be deployed.
However, your application might be deployed on the server with a different context root.
If you have a glassfish descriptor, then you can check your context root from there. However, If you do not have a glassfish descriptor then you need to create one.
In this descriptor you need to define your context root name.
<context-root>/foobar</context-root>
this means the application will be deployed on localhost:8080/foobar
Similarly, if you defined your context root as following:
<context-root>/</context-root>
Then your application will be deployed on localhost:8080/

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

Categories