Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running spring + hibernate application without actual servlet container

I have a Spring+Hibernate application, which I compile to *.war file and deploy it to Tomcat. This works for me as developer, but:

Is there a way to run that application in some user's computer, that has Java installed, but not tomcat installed?

I would even accept the solution, which uses somekinda package that actually runs the servlet container and deploys the application to user's computer, but I don't want that user must install container and configure it etc etc.

Any suggestions?

EDIT:

Basically I want user to run my web application from an executable, without having to install tomcat or other tools.

like image 890
Jaanus Avatar asked Nov 22 '25 03:11

Jaanus


2 Answers

You have a few options:

  1. if you are distributing the source code to the user, and they have maven installed, you can just run mvn jetty:run or mvn tomcat:run to build the application locally and run it within a servlet container started by the Maven plugin.

  2. You can embed Tomcat or embed Jetty in your application, so that running a main() method in your app launches a servlet container listening on a certain port and runs your application. This makes it possible to package your entire application as a single .jar file and have it be run with java -jar your.jar.

like image 101
matt b Avatar answered Nov 24 '25 18:11

matt b


The Winstone servlet container allows for embedding the war-file inside the winstone jar, resulting in a single jar deployment which can be run either with "java -jar foo.jar" or as a clickable jar.

Jenkins/Hudson uses this. We've used it with some classpath trickery to use an exploded war.

See http://winstone.sourceforge.net/#embedding for details.

This is most likely the most elegant way to do this at the moment.

like image 43
Thorbjørn Ravn Andersen Avatar answered Nov 24 '25 19:11

Thorbjørn Ravn Andersen