3

I have a working Spring MVC application(doing everything I wanted when deployed to jboss) and now I'm looking a way how to start my application from a jar. What I've though of is when starting jar, first some kind of web server should be started in order to be able to run the application.

And I've tried like a tons of combinations with jetty(lost about 2 days already), and I failed every one of them, mostly suggestions from https://stackoverflow.com/tags/embedded-jetty/hot

My main weakness is that I don't really have thorough understanding of servlets, contexts and so on. Terms which I see on a regular basis while browsing google search, maybe I found a solution already but didn't understand it.

Has anyone done something similar? And yes I've asked similar question for tomcat :

Maven tomcat plugin

Community
  • 1
  • 1
London
  • 14,986
  • 35
  • 106
  • 147
  • Is there a reason you don't simply want to deploy it as a `war` file, which is intended to run on application server such as jetty or tomcat? – Johan Sjöberg Feb 09 '11 at 21:30
  • @Johan Sjöberg there is no really valid reason which I would say, I just thought it would be more neat to run jar and have it all instead of installing/deploying to application server. – London Feb 09 '11 at 21:33
  • 2
    Spring MVC shouldn't be relevant to this problem. If you can start up a webapp in embedded jetty, then Spring MVC should work just as well. Show us the code you're using to configure and start the Jetty server. – skaffman Feb 10 '11 at 08:57
  • Assuming license permits, why don't you provide a tomcat or jetty zip with your application inside it? This way, users can unpack and start the app server and be served with your app – Raghuram Feb 10 '11 at 09:15
  • @Raghuram: Because jetty is an order of magnitude smaller and lighter than Tomcat. Very appealing for embedded use. – skaffman Feb 10 '11 at 09:53

1 Answers1

2

Yes, I've done this sort of this several times, and it's fairly straight forward if you know how the bits work.

Since you've explained that you don't know how the bits work, that's going to be a bit harder :)
But they're not too hard to learn, and the easiest way to learn is by doing - so you're heading down the right path.

The accepted answer here: Executable war file that starts jetty without maven is some of the best advice you're going to get on this topic.

I would suggest:

  1. Create a WAR to start with (which you probably have from your JBoss deployment)
  2. Get that WAR running under standard Jetty (fairly straight forward, with lots of tutorials around)
  3. Then follow the advice I linked to, to turn embedded Jetty into your WAR file.

If you run into any issues, ask specific questions with specific examples of what went wrong, and we'll try and help out.

Community
  • 1
  • 1
Tim
  • 6,406
  • 22
  • 34