How to deploy web app to tomcat without eclipse? - java

To my knowledge, to deploy my web application to tomcat, I need to move the war file under webapps in tomcat home. And in eclipse, in order to do that I right click on the server and select "Add and Remove", then add the projects to deploy them when ran.
Without eclipse, I have to make the war file myself by using jar -cf projectname.war * but I don't at which directory should I use this command. Also, should I compile all the sources in the src folder first?
To sum up my question, what is the step to run my web app on tomcat without using eclipse? I want to know what eclipse have done for me under the hood.
Thanks in advance!

Related

Deploying external wars in Tomcat via IntelliJ Idea

I have a project that is dependent on two war files being deployed to Tomcat. So every time I want to test it, I need to build an artifact and manually deploy it alongside the two wars. Is there a way to somehow add those war files to my Idea project so they can be deployed automatically by pressing Shift+F10.
I would deploy it manually, but I have several people working on the project and it would greatly simplify the communication.
Wars are external and they have no sources, so creating new modules/artifacts out of their source is out of the question.
Could you help me?
Since the link on the accepted answer is dead, here is the process, step by step (I'm using Intellij 14):
1) Select Run/Edit Configuration
2) If no Tomcat Run Config exists yet, create one
3) Select the Tomcat run config just created, on Deployment tab, under Deploy at server startup section, click the "+" (right sidebar), select External source, and select your war file.
You can add external webapps to deploy at startup at the Deployment-Tab of your tomcat runtime configuration page.
https://www.jetbrains.com/idea/help/run-debug-configuration-tomcat.html?search=tomcat#d884440e708

how to Debug war file inside tomcat

I just started to work on JSF. And i followed some steps. At last step i created project configured it. After build the project, eclipse created target folder inside of my jsf project. i moved the war file to webapps folder of apache tomcat.
After localhost:8080/firstJsfApp it worked successfully.
But when I changed something on this project and it recreates the .war file. and I have to move it to tomcat folder again (repeatedly).
Is there anyway to make this easier?
You can deploy your webapp to tomcat directly from Eclipse:
1st. Open the "Servers" view in Eclipse, and it will allow you to configure a tomcat instance.
2nd. Add your webapp to the tomcat
Then you can debug and hot deploy any changes to the project.
Here is a link were you can run tomcat in eclipse: http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html

How to deploy Java/Spring application on my own system in Apache tomcat server.?

Hello all master minds,
I have created a java spring application in eclipse with mysql db.
Now I can run this application using >Run on server in eclipse,but I want to know how to deploy this application on my own laptop(windows 7).
I have already configured server,by localhost://8080 I can see Apache tomcat is configured.
Give me simple steps so that i can just run that software using browser via its link like
http://localhost:8080/PMS
PMS is my project name.
Thanks in advance.
You can install tomcat-manager in order to deploy your war using a web interface: Tomcat 7 manager
Another option is to copy your war file into tomcat webapps folder. Your container will auto deploy your war: http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html#Deployment_With_Tomcat.
The easiest way, since you are using eclipse is to just export your project as war and then put that war (naming it PMS) in webapps directory in your tomcat.
Once started, Tomcat will deploy that war on http://localhost:8080/PMS
You have to do the following steps:
Right click on project>> Export (Export as WAR file).
or if you are using a maven project then you can give a maven build.
Copy that WAR file, (you will get that war file inside the project folder in your workspace) to the tomcat_Installed_Folder/ webapps
Inorder to deploy the app from outside eclipse,
goto tomcat_Installed_Folder/bin
and double click on startup.bat
then you could see a console.
For detailed logs of deployment, goto tomcat_Installed_Folder/logs
ALL THE BEST :)

Deploying war file in STS using gradle

I have a web project in STS, that iam looking to deploy in Tomcat. The build file for the project is written in GRADLE. Using GRADLE'S build script, a war file is generated in build/libs.
But STS looks for the war file in workspace/metadata/plugins/org.eclipse.wst.server.core/ folder.
Now If I manually copy the generated WAR file from build/libs to this workspace/metadata/plugins folder, and then start the tomcat, everything works fine but I am not able to debug using breakpoints in STS.
How do I make sure that the war file from build/libs gets moved to workspace/metadata/plugins folder?
And, Why is STS looking to find the war in workspace/metadata/plugins folder. As the app-server is tomcat, should it not be looking in Tomcat/webapps folder to find the war?
I am not a eclipse fan nowadays but did you run eclipse plugin? you can add it to the gradle file
apply plugin: 'eclipse'
and then just run
gradle eclipse
check Eclipse Plugin
I don't believe STS deploys/runs your war file directly. That is, if you select the project and say "Run on Server", STS/eclipse will generate an exploded war to the wtp.deploy directory defined. You can control/alter this by editing the "run configuration" for your server. Just go to the "Arguments" tab and change the setting for the "-Dwtp.deploy".
You should really only use this STS mechanism for development purposes - as it is invaluable for that. To deploy an actual warfile to Tomcat you have a variety of options. You can start a tomcat instance with the manager UI enabled and upload the war file from the Tomcat GUI, you can just manually drop the war file into Tomcat's deployment area, or probably your best option - extend your gradle build scripts to include deploying the generated war file to a tomcat server. Hope this helps some.

Tomcat not uploading all files

When i make the war i see the XCV.Jar, but I add the project on Tomcat (IDE eclipse), and when I deploy it, I have all jars except XCV.Jar (This jar is the parent of the project I deployed).
When you deploy to Tomcat from Eclipse it often fails to clean up the work directory directory. Try to clean $TOMCAT_HOME/work/Catalina// and the web apps directory then try redeploying.
If you are running tomcat inside eclipse you're asking for trouble. Its often better to build and validate the .war independently(with ant or maven) then deploy manually or with a script.

Categories