tomcat is not autodeploying my .war file - java

i hope this is no duplicate. I allready searched for an answer, but did not find anything that fits.
I have a .war file called "app.war" and put it into the webapps folder of my tomcat. When i start tomcat, the .war file should actually be deployed, but it does not.
In my server.xml unpackWARs and autoDeploy is set to true. The tomcat service in the system is installed.
Does the content of the war file needs to have a special structure? I have the following structure:
I create the .war file with gradle by using "gradle build". My project structure is a typical maven java webapp structure.
Is there maybe anything missing in the war file? I have no more idea why the war file is not being deployed. What is also strange to me, is that when i unzip the war file in the webapps folder and restart my tomcat, the app won't be found by the tomcat.

Did you checked the permission of the war file and the webapps folder? Commonly tomcat is started by a user different to root , so , If you copied the file as root, the tomcat process never can access it .

Related

WAR file can't be deployed on Tomcat 7 without wtpwebapps folder

I am facing a problem by deploying a War file on a Tomcat Server.
My Tomcat Server configuration as follows:
My steps to deploy:
I created a WAR file in Eclipse Kepler (Windows 7 64 bit, no Maven used).
Uploaded it with a Tomcat Web Application Manager.
Clicked deploy.
Tomcat unpacks WAR file in tomcat/webapps and throws me NullPointerException. It is missing some files that should be imported to project to work it right.
When I was working in Eclipse, as a source for these files I gave a workspace path, given in the Server settings and adding the wtpwebapps folder, which was offered by Eclipse by default. So my complete path looks like this:
C:\Users\myUserName\kepler\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myProjectName\WEB-INF\classes\project\fdsProject\FDS.prj
Now, when I deploy the project, it locates in a webapps folder, not in wtpwebapps and if I try to start in a browser, it shows me NullPointerException. But as soon as I copy the wtpwebapps folder from my workspace to the tomcat installation folder, near webapps, my project is starting successfully.
It means that I cannot start my project on another server, just deploying a standalone WAR file. I must add manually the wtpwebapps with my project in into the tomcat server installation folder. How can I optimize it and start project just with a WAR file deployed?
Thank you!
EDIT
My project structure is looking like this:
Stop the Tomcat Server
In the settings view Tomcat Server settings in Eclipse -> Server
Locations, check Use Tomcat Installation(...)
Now, you can change the Deploy Path, if you want webapps, then input it.
EDIT
The values below control how tomcat deal with war file
autoDeploy="true"
unpackWARs="true"
Just search these values in your server.xml file and edit values as you need.
If you want to be able to deploy your app as a WAR file, you need to refer to everything within it relative to the app itself, not with absolute file paths, not even as file paths if you can. If you have code that requires a java.io.File, rewrite it. The point is that you don't care where things are, you just care about how to get to their contents. For a Servlet, you can read anything on the web app's classpath by calling getResourceAsStream() on the correct class or classloader.
See getResourceAsStream() vs FileInputStream .

Deploying WAR FILE in Microsoft Azure Web App

I have created a Microsoft azure web app and configured java version 8 and tomcat latest available. As per their documentation , I have uploaded my WAR file to d:\home\site\wwwroot\webapps\ROOT .
Screenshot of MY Directory
wen iam trying to access, giving me a 404 error.Please help me to fix this
as documentation say :
you can upload your application by placing your WAR in the webapps folder.
in tomcat's webapp folder you copy war files, tomcat detects the presence of one of those files and unzip it to a folder corresponding to the name you chose for your file, so if you copy toto.war to
$TOMCAT_HOME/webapps/
after tomcat deployed your war file the folder will look like
$TOMCAT_HOME/webapps/toto.war
$TOMCAT_HOME/webapps/toto (folder being the unzipped version of your file)
ROOT folder is just a special case of that for the webapplication that is served without using a context.

How Upload My .War file in server

I new to deploying project n server.How to deploy my war file virtual private server(VPS), and how to extract .
my war file working in my local pc .Any one please tell me the steps to deploying a project
If your server is used Tomcat to deploy your war file,you may follow these steps:
Open your terminal ,and send your war file to you VPS by scp.
Login in you VPS and use w3m to open tomcat management page,you will find Tomcat Manager,just enter.
Then you can select your war file and deploy it to you host.And Tomcat will extract the war file for you and put it in the correct path.
For extracting war file, In netbeans
When you right click your project and select clean and build, then right click again and deploy. .war file will be created inside dist folder of your project.
for detailed explanation check here

Deploying a Dynamic Web Project with Tomcat

I currently have a working servlet created in Eclipse. When running it from the Tomcat plugin, everything works, and my app shows up at localhost:8080/project_name/. However, when I package the project into a .war file and place it in the /webapps directory of Tomcat and start the server, the servlet cannot be accessed. In Terminal, I can see Tomcat loading my project, and a temporary folder of the unarchived project is also created in /webapps. However, I simply cannot access my servlet.
Note:
I'm using Tomcat 7 and I don't have a web.xml file in my project.
How are you creating the war file? Check if your war files contain jar files under WEB-INF/lib folder and if the class files are not missing. You can easily verify it under tomcat/webapps/[project name] folder.

difference between wtpwebapps and webapps folder in tomcat

when I run my dynamic web project from eclipse it gets deployed to wtpwebapps. However I want to deploy a war file to tomcat so when I checked here in SO this came up
How to deploy a war file in Tomcat 7
It says I have to deploy to webapps folder in tomcat.
Can anybody please explain me the details between wtpwebapps folder and webapps folder in tomcat and also if I can deploy war files to wtwebpapps folder instead of webapps folder.
wtpwebapps is an eclipse-specific folder created when you run a dynamic web project on Tomcat within eclipse.
Webapps directory is within the Tomcat home and it's where you copy over your WAR files manually.
Recently, i've struggled with webapp strange behavior while debugging in Eclipse. I've noticed that it was double deployed.
My setup was:
web module with context path that differs from document base;
enabled autoDeploy in server.xml;
and deploy was set into webapps directory.
When checking tomcat-manager i've noticed that this webapp was deployed once with its context path name and once with document base name.
Here is what the documentation states (All credits goes to octopus, Tomcat docs):
If you want to deploy a WAR file or a directory using a context path that is not related to the base file name then one of the following options must be used to prevent double-deployment:
Disable autoDeploy and deployOnStartup and define all Contexts in server.xml
Locate the WAR and/or directory outside of the Host's appBase and use a context.xml file with a docBase attribute to define it.
And, i believe it's the main reason to use wtpwebapps instead of webapps for Tomcat with Eclipse.

Categories