Jaanus
Jaanus

Reputation: 16541

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.

Upvotes: 2

Views: 2172

Answers (4)

vector
vector

Reputation: 7576

Not a direct example, but potentially useful example of something similar: http://www.zimbra.com/products/desktop.html and http://www.zimbra.com/products/zimbra-open-source.html

Upvotes: 0

Vikdor
Vikdor

Reputation: 24134

You can certainly run a spring +hibernate application from command line, using the ClassPathXmlApplicationContext to load the spring configuration file in your main method to initialize the spring container and rest of the wiring.

However, to run a web application written using servlets or similar paradigms that use Java Servlet Specification, then you need a servlet container like Tomcat, AFAIK.

Upvotes: 2

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.

Upvotes: 3

matt b
matt b

Reputation: 139931

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.

Upvotes: 4

Related Questions