Error deploying WAR files - java

I created a dynamic web project in eclipse and then export it as war file. I successfully deployed the war file using tomcat manager. The problem is when i try to access it , tomcat gives me 404 error.
I don't have files such as index.html inside the web app.

Check the web.xml the welcome-files section, in that section you define the files used as main pages for your application, eclipse put them by default [index.html, index.jsp, ...], you could change that configuration to your welcome page or servlet url.

Related

Spring Boot REST API war file generating 404 error

I have a REST API developed with Spring Boot.
If I run it from the IDE it works fine.
For instance, the following url returns the correct json.
http://localhost:8080/xyz
Now I want to deploy the app.
Generated a war file and deployed it locally to:
C:\apache-tomcat-9.0.43\webapps
Closed the IDE.
Then started Tomcat and accessed the following url again.
http://localhost:8080/xyz
I'm getting a HTTP 404 error.
What could be the reason?
Tomcat is starting correctly.
http://localhost:8080 correctly opens tomcat main page.
It is also correctly generating the app folder under \webapps.
After deploying your war file a folder will be generated with same name of war file.
So the Url will be http://localhost:8080/<war_file_name>/xyz
When you run with your Ide its run only Enbibed tomcat and its only run your app that why you don't need that war file name as root path. But when run your app extremal tomcat it's need to use War File name as root of your app because here root is tomcat container that run different war and each war root path its file name. That's why <war_file_name> is needed before your path.
http://localhost:8080/<war_file_name>/xyz

OpenShift deploy java configured web project

I try to deploy webproject which do not have web.xml and WEB-INF, and fully configured using spring mvc java configuration. .war file works perfectly on local machine in tomcat 7. But when I put war on the openshift application using winscp and then trying to connect to it, I get throws 404 notfaund response. Maybe someone can explain me what can be wrong. Also I use html not jsp for web content.
Should I install additionaly java to application?
Should projects be always configured with web.xml?
You can either deploy war or can add project folder like:
$TOMCAT_HOM/your-project-directory/.html,.jsp/WEB-INF/class (all java files) and WEB-INF/lib (your all jars) + WEB-INF/web.xml
make sure java is installed and all variable sets on the system
you must add all your java files in web.xml

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.

Jsp Project not running

I have created a web project which includes .jsp and Java beans pages. When I run this project with eclipse, using tomcat it works perfectly fine, I deployed the project successfully, the program runs and I receive a web page in the browser.
But when I try to deploy war file in webapps folder of tomcat6 and run on browser it gives error –
This is the error I see on the page:
HTTP status 404. Description: the requested resource is not available.
What might be the problem?
Check if you have file index.html/index.jsp in your war if it is not there then you have to either need to change the name of file that is opened in context "/" or you have to make changes in list.
To create WAR file using eclipse, follow the option File -> export -> Web > War File and finally select project and destination folder. To deploy war file in Tomcat, place the war file in Tomcat Installation Directory > webapps directory and start the Tomcat.
Hope this is useful for you !!

where to copy servlet files in apache tomcat server to work fine with web?

Can anyone guide me how to get Servlets working in Apache Tomcat server? I can run the Servlets from Netbeans without problems, but I don't know where to put the class files in Tomcat.
In tomcat:
class files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/classes
jar files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/lib
(and if course you'll need web.xml in WEB-INF)
They go in Tomcat/webapps folder. There are several ways to deploy a JSP/Servlet webapplication on Tomcat. They are all described in Tomcat Web Application Deployment HOW-TO.
If you already have developed the webapplication in Netbeans, then Netbeans should already have build a WAR file of it in the /dist folder. You just need to drop the WAR file in Tomcat/webapps folder and Tomcat will automatically deploy it during startup (or even while running, this is called hotdeploy).
If you want to develop without an IDE and/or don't want to create a WAR, then you just need to put a folder representing the context name in Tomcat/webapps, e.g. Tomcat/webapps/contextname. It will become the public web content. You can drop all JSP files and other static files in there. Then, for classes you need to create a Tomcat/webapps/contextname/WEB-INF/classes folder. There should go the package structure.

Categories