How to deploy a web application on Jetty - eclipse

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

Related

Servlet works in Eclipse, but not from my tomcat server

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)
...

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.

Import and run WAR on eclipse

I have a subproject in a Virtual Machine with Ubuntu which I compile with Maven and then run with mvn jetty:run.
Maven also packages it as a war.
All of this works fine and does what is expected.
I am trying to import this WAR from another eclipse in Windows so I have done it by Import -> WAR, thus creating a Web application.
I now want to run it from Eclipse so I have created a new Jetty Server and run my application as Run on Server but I am getting Could not find the main class.
What is the proper way of doing this?
Besides, I have tried deploying the application by putting it in the webapps Tomcat directory . I can see it in the Tomcat GUI and launches the index.html but when I tried to access some of the services it throws No service was found
When deploying, in the Tomcat console I can see runtime NoClassDefFoundErrors.
Is there anything that mvn jetty:run does that the tomcat regular deployment does not? How is it possible that this didn't happen in my Virtual Machine? Shouldn't those classes be all in the WAR?
EDIT:
Here is another hint. When I run the project imported from the WAR in the Ubuntu VM, either with Jetty from eclipse or adding it to the webapps folder it works fine.
It is only hen running it on Windows Host Environment when it fails.
The specific NoClassdefFoundErrors thrown on cmd is the following:
Caused by: java.lang.NoClassDefFoundError: org/ow2/frascati/explorer/
api/FraSCAtiExplorer
That is one of the modules fo the main project.
If you try to deploy your war in tomcat's webapps folder, and if you miss a class, then you probably miss a jar in your lib folder. It is probably a jar that is supposed to be provided by the web server.
We need to know which class is missing.
Finally all errors have been solved by doing the following:
First I recompiled the WAR which did work this time under Jetty in Windows cmd. I apologize as this must be due to some error I still don't know, probably sharing the wrong WAR with Windows HOST OS from the beginning.
On the other hand, the Eclipse was solved by moving the Jetty folder out of the "Program Files" directory. It seems the old Jetty 6 adapter Eclipse comes with does not recognize spaces in its route to the server.

Eclipse running a web app on an existing tomcat installation

I have an existing tomcat server running on my local machine that is being started from outside of eclipse. Is there a way to deploy my web app from eclipse to that tomcat instance without having eclipse trying to start that instance of tomcat?
It's possible using ANT scripts in eclipse which will deploy war file into tomcat directory and tomcat will take care rest of the things.
For those ant scripts you can see this below links
How Apache Ant deploys .war file to Tomcat
http://www.coderanch.com/t/423905/tools/automate-deployment-war-Tomcat-through

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