How to stop jetty runner from executing - jetty

Am using jettyrunner for executing my war files.I am using command java -jar jetty runner ex.war.But am running this jetty server from my java application by executing this commands from java.My problem is at first time its working good,but the second time if i am again executing another war file with the same code its executing the older war.i have found the reason that the older jetty server is keep on running.How could i stop this server from java in order to start the jetty server for another war.

One option should be:
http://wiki.eclipse.org/Jetty/Howto/Secure_Termination
Another would be to use the ShutdownHandler:
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java
Or don't use the jetty-runner directly like that from java code and just write a small embedded usage:
http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty

Turned out, jetty-runner.jar doesn't have a feature to stop existing jetty process ran with stop-port and stop-key.
I found the answer in https://github.com/jetty-project/jetty-documentation/blob/master/src/docbkx/administration/runner/jetty-runner.xml
Then, to stop jetty from a different terminal, you need to
supply the same port and key information. For this you'll either
need a local installation of jetty, the jetty-maven-plugin jetty-ant plugin, or write a custom class
Fortunately, I was implementing gradle build, so jetty-ant satisfied my needs.

Related

Is it possible to stop the imbedded server from starting when running the unit tests?

I'm running the gradle test task on a Micronaut project and the imbedded server is getting started.
In local that is not much of an issue, but when running the unit tests in the CI environment there isn't a database available for the server to connect to. So ideally we would run the gradle test task without starting the server.
Is it possible to configure Micronaut to not do that?
Is it possible to configure Micronaut to not do that?
Yes. The embedded server is not started by default. It is only started if you write code in your test to start it or if you mark the test with #MicronautTest. If you don't do either of those things, the server shouldn't start.

Jetty runner is not executing the war file

I have a project named as test using spring,hibernate and struts.It is running when am using eclipse.But when i export this project as war and execute it using jetty runner in command prompt it just extracted the project and listed the contents in the browser.But i want the project to be executed.I have tried with some other simple web application war using the same procedure and it works fine.But in my project its not working with jetty.
here is my code for jetty
D:\>java -jar jetty-runner-7.0.0.v20091005.jar test.war
i just listing some console output of jetty
INFO::RUNNER
NO tx manager found
deploying file:D:/test.war #/[webAppContext#86f241#86f241/,null,file:D:/test.war
can any one tell me a solution for my problem
1) use a newer version of runner, 7.6.3.v20120416
2) what context are you trying to navigate to, you might want to experiment with some of the other cli options on the runner to set the context and whatnot from the command line and experiment with that. This site has some good information on using this artifact as well.

Jetty won't work: Is there a way to purge it?

I'm a Jetty newb, but it's making life hell. First there was an Eclipse problem I described in another question. Rather than waste time on it, I decided to just run Jetty from the console. I started off importing a sample Tapestry project and was able to run it fine... the project is on the Tapestry page and is called tutorial1
I began work on my own project then and began introducing new functionality to it. At some point it stopped working. I tried backtracking my project to get it to a working state but every time I requested the home page it would just hang. At this point I still thought it was my fault, though I did think a more graceful error message would have been nice than the it attempting to load for a minute followed by a server timeout error.
I then shutdown jetty and attempted to load up the imported sample project using mvn jetty:run in my tutorial1 project directory. it doesn't work either! When I try going to localhost:8080/tutorial1 or the URL of my project the jetty console does show any output, almost as if it's not receiving the request.
I rebooted my entire machine but that doesn't help. I am not familiar with jetty architecture and am unsure if there is a way I can purge all my files from the jetty web application directory.
Any ideas?
Cliffs Notes:
Downloaded Tapestry Archetype project with maven.
Executed jetty from the command line using mvn jetty:run
Started new project
Executed jetty from the command line using mvn jetty:run
Modified new project
Error occurred, attempted fix and restarted Jetty (Ctrl + C, followed by mvn jetty:run)
Jetty restarted, but did not seem to handle requests for any pages
Tried starting jetty from Archetype project, experienced the same problem
If your project didn't deploy correctly, jetty won't serve any pages (they will either return 404 or some error in the 500s).
Look at the log folder and check if it is getting correctly deployed.

Tapestry webapp with embedded Jetty

How can I configure a Tapestry5 project to run standalone (via java -jar) with embedded Jetty?
I'm looking for a short "recipe" regarding Tapestry5, Jetty, configuration of servlets/ handlers/ whatever is needed to connect the dots...
I've seen a few dots: How to Create an Executable War, Configuring Tapestry (ref Tapestry as servlet filter)
Edit: I'm thinking about a standalone running webapp due to server circumstances. It doesn't have to be embedded Jetty, but I can't rely on a stable appserver. Still looking for a recipe, though, so I don't spend much time on dead ends...
Also, I'd like for Jenkins (Hudson) to be able to stop and start the server automatically when deploying updates - I don't know if that influences what I can do with Jetty, f.ex.
Well, i believe this is a general "how to run a war question". Assuming you indeed have a war, you can use jetty or winstone to "run" it - see :
http://winstone.sourceforge.net
and
http://www.enavigo.com/2008/08/29/deploying-a-web-application-to-jetty/
In the first case, you can directly do
java -jar winstone.jar --warfile=<warfile>
https://github.com/ccordenier/tapestry5-hotel-booking/
<-- Check its maven build
http://tapestry.zones.apache.org:8180/tapestry5-hotel-booking/signin
I did some digging, and this is the short recipe I basically ended up following:
Start with the Maven Jetty plugin as configured in the pom.xml of the Tapestry 5 archetype
Add the stopKey and stopPort attribute to Maven Jetty plugin configuration
Let Jenkins CI run maven target jetty:stop and then clean install
Let Jenkins run shell script mvn jetty:run &
Voila - my Java app is up and running with automatically updated code, without any appserver.

how to run metro webservice on jetty in Maven project?

how to run metro webservice on jetty in Maven project??
As per this source.
If you place your web service in a WAR file, like here, it should run fine
on Jetty, just as it would on any servlet container. There might be some
subsequent Jetty-specific configuration needed, but I would try to deploy
the WAR first on Jetty and see where it gets you.
If you want to embed Jetty, instead of running on Jetty standalone, this
might give you some pointers.