I am going to ship out the first version of webapp base on Javalite framework. Thanks the framework, it makes the developing rapidly :). Here are some goals in my production env.
- I would like to use
maven-assembly-pluginto assemble all dependencies into one jar, named likemyapp-with-dependencies.jar - I'd like to run the webapp using command line:
java -jar myapp-with-dependencies.jar, so that I can create daemon service formyapp
I've checked all sample apps of Javalite repo on github, Below lists the entry Main.java in development env
public class Main {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
WebAppContext webapp = new WebAppContext("src/main/webapp", "/"); // <- should package as war in production?
webapp.addAliasCheck(new AllowSymLinkAliasChecker());
server.setHandler(webapp);
server.start();
server.dumpStdErr();
server.join();
}
}
new WebAppContext("src/main/webapp", "/"); only works on development mode? and how to change it to production mode?
The question may be related to embedded-jetty. If you have any experiences on shipping Javalite on production env, could you like to share it ? Thanks!
The example you found is a very simple way to run Jetty embedded. The other question you asked is about ActiveWeb projects running in a different environment.
Please, see http://javalite.io/app-config. We always use AppConfig to load properties from property files that correspond to a current environment. That page contains all the information you need to setup your system for different environments
Step 1:
Step 2
Add properties to your property file, for instance
development.properties:Step 3
Pull properties with a
p()method:When you run locally, it will be reading the
development.propertiesfile by default.If you set an environment variable
ACTIVE_ENV=production, then you code will be reading from theproduction.propertiesfile.How we run JavaLite apps in production environment.
Generally, we develop using a Jetty Maven plugin - there are many examples of that: https://github.com/javalite
Our standard Maven build creates a WAR file that includes all dependencies as jar files under WEB_INF/lib - that is, we do not create a jar with dependencies. Once we have that WAR file, we deploy it on a standard production container, like any other Java app (JBoss, Tomcat, etc.).