Spring Boot REST API war file generating 404 error - java

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

Related

Error deploying WAR files

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.

failed ear file deployment on jboss server

I'm trying to run a simple Java EE app on jboss wildfly 8 server. I just by selecting Run on Server menu. but deployments folder is empty. browser shows error 404 not found by accessing address:http://127.0.0.1:8080/EjbTest/. Any idea?
Finally, I figured out what problem my ear file had. As EAR File Structure says, my ear file didn't follow the structure. after putting necessary files into .ear file, it worked with no problem.

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.

Deploying GWT RPC app in Tomcat

As per the Google tutorial, I have developed the basic StockWatcher application, that makes an RPC call to the server, which sends some data, which is displayed on the client.
I now want to deploy it in Tomcat, such that if call something like localhost/StockWatcher, I should get the same experience as when running the app from GWT in development mode.
How do I do this? There is a similar topic here, but I couldn't much understand it. If I only copy the compiled war folder, what happens to the GreetingServiceImpl class which handles the RPC? And how do I do the mapping such that localhost/StockWatcher maps to localhost:8080 (something like Mod_Rewrite)?
Steps to deploy war on TOMCAT
1)Compile you gwt web application
2)Copy the war file
3)Add all libraries(jar files) in lib folder of war file
4)Rename your war as "myapp"
5)create a .war file with that "myapp" folder
6)start tomcat with catalina.bat run.
For step5 (generating .war file ):Preparing .war file from command line
Normally if you deploy well your war directory and you are able to start tomcat you have done everything. If you access your page using this url : localhost:8080/StockWatcher gwt will know that it must use that url as a baseURL for all gwt/rpc requests.
To generate the war using Eclipse : right click on the project -> export -> war. You will have the war exported with all the dependencies inside. just unzip it in the ROOT directory

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 !!

Categories