I am reading "Java Webservices: Up and Running" to study for my OCE WSD certification. I installed Apache Tomcat 7.0.54 and am able to view the Tomcat homepage at localhost:8080. I am in chapter 1 of the mentioned book and have built my first project with the .war deployed into ..\apache-tomcat-7.0.54\webapps\MyWebservice.war. I installed CURL to try a simple ping with...
curl -v http://localhost:8080/predictions/
I am getting 404 error: Not found. I also get this while using my web browser to view the same URL. I thought that since my .war file was deployed into my apache tomcat 'webapps' folder, simply starting the Tomcat server would pick up that .war file and start the webservice. Any ideas what I might be doing wrong or steps I might have missed to start my webservice?
Edit for Solution:
curl -v http://localhost:8080/MyWebservice/
check the name of the application mentioned in the web.xml.
If web.xml is not present, the name of the application would be the name of the war.
Tomcat maintains hierarchy where the servlets are of the scope of the application.
Try using
http://<>:8080/<>
it should return you something. If it does, then try adding the servlet name.
hope it helps.
Probably you want http://localhost:8080/MyWebservice/predictions/ since Tomcat deploys War files the context name equal to the War file you use.
Related
I'm new in Java EE and Tomcat.
I worked on a REST Java application in OpenShift with JBoss EWS 2.0 and I had no problem. Recently, we got a server that I have to run my web service on.
Following How to deploy a war file in Tomcat 7, I went to my application root and used this command:
jar -cvf myapp.war *
Note that myapp is my application name for example.
I put the .war file to /base/path/of/tomcat/webapps/ and went to Tomcat GUI App Manager.
I saw that Tomcat created a folder with my .war name and put files into it, so I started my app but when I went to http://localhost:8080/myapp/ it returned 404. However, in OpenShift, when I opened it (opened root path), it displayed the index.html insomuch my webservice path is not valid and does not work.
please guide me and thank you for your time spent on my question.
I have to write an answer because I can't comment.
I suggest to give us a copy of the web.xml file.
On another hand, you have to know that Tomcat is a Servlet Container and JBoss a full stack JEE server. If you have EJB in your web-app it will not works.
AS Clément Duveau says an EJB application cannot be deployed in a Servlet container (like Tomcat). An EJB application needs to be deployed in an Application Server like JBoss, Wildfly, GlassFish, Weblogic, Websphere, TomEE, etc.
The most similar server to Tomcat (Java EE compliant) would be TomEE.
Suggestion: If you need to use Tomcat, you can change EJB for Spring Framework.
it is simple.
there is two way to deploy a war file on tomcat with custom path
the first one is to
renaming your war file to custom URL you want (for example the war file name is java-web-app-1.0.war and your path is myapp so you have to rename it to myapp.war)
and copy and put it under {tomcat-path}/webapps/, then the Tomcat/TomEE does its job. (it creates an empty directory with the same name of your war file)
after about 1 minutes you can check the path (in this example must be localhost:8080/myapp and see your war file was deployed)
the second one is to use Tomcat GUI.
go to Web Application Manager part.
it's a page like this:
in Deploy box just fill the Context field (it will be the custom path and in this case is myapp) and then choose the war file and push deploy button.(do not need to fill XML Configuration file URL field)
then it gives you a message like this:
this means your war file was deployed on the custom path.
I've got a project in Eclipse, with a .war file inside it. I'm using Spring for the project, with the help of Maven too.
I've installed Tomcat 8, but I'm having trouble deploying the webapp to Tomcat. The Tomcat runs without errors and the console output of launching the Tomcat looks like it is successfully deploying it, however when I go to localhost is just displays the generic Tomcat home page saying I have successfully deployed Tomcat.
I've tried changing my server location to use the tomcat installation, I've changed the location in the properties of my server to not be the workspace metadata.
When I add jars to the tomcat, I click on my project, and under it it lists the Spring jar if that is of any relevance.
I don't really know what else to put here at the moment, but I'm at hand to respond immediately to any questions or any more info that you require.
Thanks.
EDIT:
http://localhost:8080, it leads me to this: http://i.imgur.com/82lmpai.png
My tomcat console output is: https://gist.githubusercontent.com/J-Owens/8164b3ec6dbed9986322/raw/6756486aad0092647bbea8f315c42ac5ba9550b1/tomcatconsole
Each war file will have a name associated with it. When you use localhost:8080 as the URL, Tomcat will use the war with name ROOT under tomcat/webapps to display on the browser. By default, Tomcat will have a ROOT war that comes with the tomcat bundle. If you need to open your project, you will need to use localhost:8080/<your-war-name> to open your project's page. Alternatively, you could remove everything under tomcat/webapps and rename your war to ROOT to be able to access your project pages with the localhost:8080.
I have created an application in Java EE, I have learned how to deploy it in the tomcat server using the manager app or by copying the war file to the webapps folder. Now I can start the tomcat server only from the Netbeans IDE.
I want to know how to start the apache tomcat server without using the IDE and run my web application from the war file deployed. If I'm headed in the wrong direction please correct me. I'm asking this to gain knowledge of how to deploy the .war file in another server system without using the IDE only the tomcat server.
The shell scripts located in "CATALINA_HOME/bin" are the most bare-bones way of getting Tomcat up and running. The two scripts capable of starting Tomcat in this directory are named "catalina" and "startup", with extensions that vary by platform.
In your tomcat installation directory, there would be a startup.bat/sh file which will start the server for you. Moreover you can see the conf folder as well if you want to change any configurations. Whatever war you copy to the webapps folder will be automatically deployed
I have made a project in Eclipse. It is running on local tomcat server. But when I deploy this war file in external tomcat server webapps directory. It is deploying correctly but when run on browser, Page not found. But I checked that directory and pages exists there but tomcat says Page not found. Then I made a demo.txt file inside project directory but it is also not found by tomcat. Now, I created a directory inside tomcat Webapps. It is found but my Project directory not found which exists there. What should I do now?
Check the port number. If not 80, try 8080 then.
There may be something wrong in web.xml or in library.
You can check tomcat Manager whether the Context is false(if then you will get only 404 error).
You can check the tomcat log files to get the exact error.
I am not familiar with build processes on Eclipse with javascript (HTML5) and Java resources. But recently I got a war file from someone who asked me put it on tomcat (since the server where I used to access the project from is down). I tried putting it under C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps... and then I restarted the tomcat which I have mounted on eclipse... and then I thought I will be able to access the project using localhost
http://localhost:8080/<warprojectfilename>
But I get 404...
Could someone let me know how could I deploy it on tomcat and access it using localhost like a website.
Thanks
it looks like you have got some other Tomcat (or other server using port 8080)running on your machine... please check which tomcat instance is running and stop it, or stop any other server running service that you mentioned is working fine...
You can stop tomcat server by going in to tomcat/bin
and execute
sh shutdown.sh
or
shutdown.bat
in windows
and to deploy war file to Tomcat server :
1) go to your Tomcat path
2) open webapps directory
3) paste your war file here
4) restart tomcat
5) now you should be able to access your app
File -> import ->Web-War file this will import your .war as a web project.
goto Servers->tomcat->web modules-> add the imported web project. restart tomcat. you should be good
Since it was all static resource (javascript files)... I decided to extract the whole thing in a static web project on eclipse and it worked.