I have done a maven project in my eclipse and was generated a war file in my system.I want to run that war file in another system without using eclipse.Is it possible to run without downloading JDK and eclipse..
You can refer the following link to run WAR with tomcat -
Deploy war in Tomcat
or a video - Deploy the war in Tomcat Video
Well, if this suffice your requirement, it is good else please mention the specific issue, if there is that you are facing.
The .war file stands for 'Web Archive'. This is a packaged web application, which can be run by an Application server (Examples: Glassfish / Tomcat / Weblogic, Wildfly)
The process of making an application server run the .war file is called Deployment.
For example, a .war file can be deployed to Tomcat application server (I.E., made to run by tomcat) by simply copying the .war file to the /webapps folder of Tomcat.
Here are the steps to deploy .war file on Tomcat:
Step 1: Build the .war file for the web application.
Suppose that the .war file is "my-app.war".
Verify that the my-app.war file contains the following:
/WEB-INF/ folder and
/WEB-INF/web.xml file
Step 2: Verify the following settings in Tomcat config.
(This step can be skipped if Tomcat was installed with default settings)
autoDeploy : true
unpackWARs : true
(Note: These are default values. These will be set to true if Tomcat is installed with default settings.)
Step 3: Remove any conflicting entries or stale entries from Tomcat config.
For example, if the new app to be deployed is 'my-app', then make sure that the existing config of Tomcat does not have 'my-app' already registered for another application.
This can be checked by trying to browse http://localhost:8080/my-app.
If this link works, then it means that the name 'my-app' was already taken.
Another way to find if the name already exists:
If Tomcat is installed in "C:\Tomcat8",
then the registration for 'my-app' can be found at
C:\Tomcat8\conf\Catalina\localhost\my-app.xml
Step 4: If steps 1, 2, 3 are cleared, then copy the my-app.war file to 'webapps' folder of Tomcat.
If Tomcat is installed in "C:\Tomcat8",
then the my-app.war file can be copied to
C:\Tomcat8\webapps\my-app.war
Step 5: Wait for Tomcat to automatically detect my-app.war file inside webapps and extract it to webapps/my-app folder.
Tomcat usually does this automatically. However, this process may sometimes not work either due to file permissions (Example: User does not have write permissions on webapps folder, or Tomcat is installed to C:\program files, which has read-only permissions) or due to folder being locked.
Try restarting the Tomcat service to fix the issue.
If restarting Tomcat does not fix the issue, then verify permissions of Tomcat service and re-install / execute Tomcat with the necessary permissions.
More information:
https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Top-5-ways-to-deploy-a-WAR-file-to-Tomcat
https://tomcat.apache.org/tomcat-8.0-doc/deployer-howto.html
https://dzone.com/articles/how-deploy-war-file-using
https://developer.jboss.org/thread/268260
Related
Am using IntellIJ IDEA Ultimate Edition 2020.1.2 and Tomcat 8.5.55 on macOS Catalina 10.15.5
Have setup a run configuration inside IntelliJ for Tomcat.
Am able to run Tomcat via IntelliJ IDEA and everything works (am able to run tomcat and see my webapp inside Google Chrome & see catalina.out via IntelliJ) but when I go to the webapps dir, I don't see the unpacked war file anywhere?
cd $CATALINA_HOME/webapps
ls
Directory listing:
ROOT docs examples host-manager manager
Question(s):
How can I setup / edit my Tomcat local run configuration to move the war file (whether exploded or not) inside $CATALINA_HOME/webapps?
Where is this IntelliJ generated war file located?
Configure the artifact output path to be under webapps directory.
In the artifact output directory.
Normally there is no need to change it, IntelliJ IDEA instructs Tomcat to deploy from the configured artifact output location.
In my Eclipse I have created a Dynamic Web Project, which runs on a Tomcat7. If I modify and save any file in the project, eclipse automatically republishes the project on the Tomcat (copies files in a temporary Tomcat directory) and restarts the Tomcat. This means I loose all sessions.
Is there a way to tell eclipse to automatically copy modified files in the Tomcat directory but only restart the Tomcat when manually restarting Tomcat?
Even better would be: Copy any modified files in Tomcat directoy but restart Tomcat only when I modified a file with extention *.java
Thanks for your help!
You should start Tomcat in hot deploy mode (supported only in debug mode). There is a good guide for this here.
It is possible to deploy web applications to a running Tomcat server.
If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the appBase. For this to work, the Host needs to have background processing enabled which is the default configuration.
autoDeploy set to "true" and a running Tomcat allows for:
Deployment of .WAR files copied into the Host appBase.
Deployment of exploded web applications which are copied into the Host appBase.
Re-deployment of a web application which has already been deployed from a .WAR when the new .WAR is provided. In this case the exploded web application is removed, and the .WAR is expanded again. Note that the explosion will not occur if the Host is configured so that .WARs are not exploded with a unpackWARs attribute set to "false", in which case the web application will be simply redeployed as a compressed archive.
Re-deployment of a web application if the /WEB-INF/web.xml file (or any other resource defined as a WatchedResource) is updated.
Re-deployment of a web application if the Context Descriptor file from which the web application has been deployed is updated.
Re-deployment of a web application if a Context Descriptor file (with a filename corresponding to the Context path of the previously deployed web application) is added to the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory.
Undeployment of a web application if its document base (docBase) is deleted. Note that on Windows, this assumes that anti-locking features (see Context configuration) are enabled, otherwise it is not possible to delete the resources of a running web application.
Note that web application reloading can also be configured in the
loader, in which case loaded classes will be tracked for changes.
For more details, you can follow this tutorial
Related Link:
Tomcat Deploy Procedures
Hot Deployment
How to configure hot deploy in Eclipse?
My understanding is when running tomcat inside of eclipse, during publishing... eclipse will copy files based on the settings in Web Deployment Assembly to tomcat directory. I added my app to Tomcat 7 thru Server --> "Add or Remove...", when I start tomcat, I don't see any files been copied to /usr/share/tomcat7/wtpwebapps/myapp folder. BTW, I have all the folder structure (folders) under tomcat directory, but missing all the files (like .class, .properties, .xml and ...). This is the error I am getting when start tomcat. BTW, the directory show in the pic is the directory under tomcat. I thought the publishing process copies files from eclipse to tomcat dir? It looks like it's trying to copy files from tomcat dir to somewhere else. What am I missing? My Server path and Deploy path are all correct.
It's a permission thing. Also I recommend install tomcat manually instead of running apt-get.
Either https://askubuntu.com/questions/17223/permissions-problem-when-copying-files-to-usr-share-tomcat6 or http://www.frattv.com/tomcat-can-t-start-from-ide-eclipse-luna-wtp-intellij-idea-in-ubuntu/ will work.
I'm having issues with running my application through intellij. I would like intellij to not run my application from its own folder (C:\Users[name].IntelliJIdea13...) but instead place my war file or exploded war into my tomcat /webapps folder and run form there. What is happening is i'm having issues accessing resources as my servletcontext points to my tomcat instance by the exploded war is not there, its in Ideas folder structure.
Currently I set CATALINA_BASE in my launch options which allows me to pull the correct keystore to run but that is living outside of the war.
I have tried changing where my artifact outputs too but what ends up happening is I get weird webclassloader errors due to library collision.
I have a Java Web project (Struts + Spring) working perfectly in my localhost. I have to deploy it on my website, but the Tomcat Manager interface given by the webhost says it cannot upload a WAR file due to safety reasons. When contacting the tech support I was told it is not possible to upload a WAR and that I should try deploying my project by uploading the files directly (I have FTP access).
My problem is that no one at the tech support gave specific instructions on where I should put my project files (I don't know if it should be on de same folder the WAR would be sent to) neither how to start/stop it (Will the Tomcat Manager recognize it once I upload the files?).
You can always try to upload a war file to webapps folder of tomcat.
if tomcat is running with autoDeploy set to true it will auto deploy your application.
i think that the same will happen if you upload the exploded war to the webapps, the context will be the name of the directory you put your files in.
Just place your apllication's root folder to the Tomcat's directory webapps and configure tomcat to auto deploy. Restart the server and your application will be deployed.
You transfer the files to the same place as the war file would go - but just as an expanded war.
Whether or not tomcat will recognise that the files have changed depends on the configuration of the tomcat server. I'd just give it a go - transfer the files and see what happens. If it doesn't pick up the changes then you'll need to find out from tech support how to restart tomcat.