Servlet works in Eclipse, but not from my tomcat server - eclipse

Im teaching myself servlets, found some very good tutorials and have great success in Eclipse Neon EE. (very basic servlet that just serves a simple static web page)
I installed Tomcat standalone before installing Eclipse Neon EE, and tested it and I get the regulat apache tomcat page. The tutorials I found also guided me on how to set up the tomcat server in Eclipse. They also showed me how to create a project and servlet. Even though I use 3.1, I still have Eclipse create the web.xml file.
When I run my servlet, Eclipse starts up Tomcat and does everything, and opens a browser tab within Eclipse and it takes me to http://127.0.01:9999/first/Hello and it serves up my web page. No problem. So now I export my project as WAR file, tell Eclipse to put the .war file right in my tomcat8's ROOT dir. Then i stop the tomcat8 server in eclipse and shut down eclipse. Then I use startup.bat and tomcat comes up, but then I cannot surf to http://127.0.01:9999/first/Hello from this same PC, it just gives 404 with "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."
Im not quite sure what steps I am missing?

You have to put your war file (first.war) into the "webapps" subdirectory, not into the root Folder of your tomcat server. Have a look at : How to deploy a war file in Tomcat 7
Copy the .war file (first.war) to %CATALINA_HOME%\webapps ( E.g.: C:\tomcat\webapps )
Run %CATALINA_HOME%\bin\startup.bat
Your .war file will be extracted automatically to a folder that has the same name (without extension) (E.g.: hello)
...

Related

How can I deploy a Java-Spring Maven Application on Tomcat v8.0 (Restful WebService)

I am unable to deploy the Spring-Maven Restful WebService on Tomcat v8.0. My OS is windows 7. When I deploy it through Tomcat App Manager then I get a screen with the link "Click To Enter", although I have not created any links like that. Please see the image below.
Thanks,
This is exactly how it is supposed to work. When you create a new "Simple Spring Web Maven" project in Eclipse (I guess this is what you did), the wizard creates a working Maven project that can be immediately built with Maven. The created WAR can be, in turn, deployed to Tomcat (i.e. copy the WAR file to the webapp folder of Tomcat) or whatever container you are using.
As I said in the comment, it looks like you actually managed to deploy the WAR and what you are seeing is the default home page corresponding to the "index.jsp" file, that is created by the wizard.

How to run web pages without starting eclipse

I have created a dynamic web application using eclipse. it consist of java servlet and jsp and it run on tomcat 7.2.it runs fine under any browser if run it through a eclipse, copy the address and paste it in browser while eclipse is running. I wish to run this application without running eclipse. for this i run the tomcat manually using startup command. however than when i use the website address of my web site in the browser it says resource not found. I want to run this without actually running eclipse. any suggestion please.
You'll need to deploy the war file that was built by Eclipse to your new Tomcat server. You can just copy it to <tompcat-instrallation-path>/webapps location. It will be exploded by Tomcat automatically and you'll be able to see your pages at:
http://localhost:<port>/<name-of-your-war>/...
Where <port> is usually 8080 if you didn't change it in Tomcat's config and <name-of-your-war> is the name of your war without .war extension.
You will need to take the built war file, name it ROOT.war, and place it in the /webapps directory in your tomcat directory. Tomcat gives instructions for this, you will replace the ROOT.war that is there by default. You should also check to make sure you are using the same port on which Tomcat is running.

Tomcat home page is not showing when running in Eclipse

I'm running Tomcat in Eclipse. I would like to see the Tomcat home page, however it doesn't show up. When I browse http://localhost:8080, then I get a HTTP 404 Page Not Found error.
How is this caused and how can I solve it?
Eclipse does by default not use Tomcat standalone. Instead, it overtakes its sole server engine and uses the workspace as deployment space instead of Tomcat's own /webapps folder. It also creates copies of configuration files like server.xml in the Servers project. It untouches the Tomcat installation. It untouches the Tomcat default homepage (and manager). It untouches existing deployments.
As the Tomcat homepage is not one of Eclipse projects (nor would become one), you won't see it when starting Tomcat from inside Eclipse like that. You would only see Eclipse projects which are deployed to the server by Add/Remove projects. I'm not sure why you need to see the Tomcat homepage as it has no utter value while developing Java EE web projects. But if you are really dead set on seeing it for some unclear reason, then you'd need to tell Eclipse to not only overtake its engine, but instead use the standalone installation at its entirety.
To configure that, double click Tomcat's entry in Servers view to open its configuration and in the Server Locations section, choose the option Use Tomcat installation.
You'll now be able to see Tomcat's homepage.
Again, the benefit is highly questionable. Do note that this way Eclipse will modify the Tomcat installation. So the Tomcat installation may not be reuseable across other IDEs/workspaces. You'd need to create a whole new Tomcat installation.
In eclipse,right click over tomcat server in servier view.
tomcate->properties.click switch location.
Try the following steps once:
1.Remove schoolManagementsystem folder and war file from webapps folder
2.Task Manager--> end the all java process
3.Now execute the command catalina.bat run in command prompt.
Hope this will help you .

How to deploy a web application on Jetty

I create a war file , then i executed in eclipse, like described here.
I don't know configure the context path, how can I run the war file?
There are two ways you can run your webapp using Jetty Server
Configure jetty server using Jetty_WTP_Plugin and run webapp within eclipse
Download stand alone jetty server from Jetty Distributions from Eclipse
If you use second option, you need to create war file keep war file interface /webapps folder.
I haven't used jetty but I know that its quite similar to tomcat. Just place your war file (say foo.war) in webapps directory; Start jetty by the following command in
java -jar start.jar
and hit http://localhost:8080/foo in your browser
By the way the tutorial you're using is quite an old one and may not work for jetty 8 or 9

Deploying GWT app to tomcat in eclipse

I want to use tomcat server in development mode with GWT. When I use embedded Jetty it deploys application to the current directory(where my war folder is located). So it generates all the files there. How can I configure eclipse to use tomcat server and all the deployment stuff to be copied to tomcat webapps directory. I have tried to use -noserver option in Run conigurations, but it doesn't copy any resource from war directory to server deployment directory.
Can I use tomcat server in such manner?
P.S. i want to solve this problem withou ant or maven
Using my own server in development mode instead of GWT's built-in Jetty instance
You will need to copy the contents of the WAR folder over, but only once.
Have you looked at Eclipse WTP? It allows deploying to a server right from within Eclipse.
For a GWT project, you'd then, in addition, follow that recipe: http://code.google.com/eclipse/docs/faq.html#gwt_in_eclipse_for_java_ee