Deploy Java Web Project on Tomcat without WAR or EAR - java

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.

Related

How to run war file without using eclipse

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

Deploy to Tomcat

How can I deploy a war file to Tomcat in exactly the same way Eclipse deploys to Tomcat, if I configured Tomcat in Eclipse?
Reason for asking is that when I deploy with Eclipse everything works fine (databse connection, log4j ect). But when I manually deploy the corresponding war file to the same Tomcat installation, none of my external resources like database connection, logging to files work!
You can add the external jars to $CATALINA_BASE/lib Read here
Common — This class loader contains additional classes that are made
visible to both Tomcat internal classes and to all web applications

Republish Tomcat Server in Eclipse without complete Restart

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?

Change context-root inside WAR file

I am really new to WebLogic deployments. I have the below situation:
I have a war file which is already deployed on WebLogic 8.1, I want to pick the same war and deploy it on the same server without bringing the original site down. This would definitely give me a exception saying the context path already exists. I have no way of recreating the war file, hence I will somehow have to modify the war file to change the context root. Is this possible?
And if it is possible could you also confirm that both using the same data-source(JNDI) would not cause any issues to the existing site.
Thanks,
Sahana
Yes you can deploy the same war file multiple times and yes you can change the context root. You will want to do something like the following if you cannot rebuild the war file yourself.
Unzip the war file (jar xvf myfile.war)
This isn't entirely necessary but it will help you understand the structure of the war file. Zip tools can modify a file in place. Try 7zip or use the Windows zip utility via right-click Open
Edit the weblogic.xml file with the new root <context-root>/new-root</context-root>
Rezip the war file (jar cvf mywar.war folder_it_is_in)
Here are other examples that may help as well:
How to deploy EAR application twice on WebLogic server?
How to deploy the same web application twice on WebLogic 11g?
How can I use Weblogic (12 C) without the application context in the URL?

Deploying Eclipse Java Dynamic web project on Apache Tomcat permanently

I have a Java web project in Eclipse which I run through Eclipse on Apache Tomcat.
Is there a way for me to permanently deploy the project on Tomcat such that it runs without having to open Eclipse and rather just starting Tomcat?
If yes, then what steps do I need to follow?
*UPDATE*
If I take the .war file and deploy it on another system will it work? Note that I am using a MySql database in this project. So will transferring the .war file also transfer the database?
You package the project into a war file (since it is a web project) and put that one into the Tomcat's webapps folder. The deployment should then happen automatically, when Tomcat is started.
Generate a WAR file within Eclipse. (Properties->Export->WAR File)
Place this file in the {installation}/webapps folder of Tomcat.
It should deploy now.

Categories

Resources