{"id":22798,"date":"2014-03-17T13:00:34","date_gmt":"2014-03-17T11:00:34","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=22798"},"modified":"2014-03-17T10:40:07","modified_gmt":"2014-03-17T08:40:07","slug":"war-files-vs-java-apps-with-embedded-servers","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html","title":{"rendered":"WAR files vs. Java apps with embedded servers"},"content":{"rendered":"<p>Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for distribution is to bundle them as a WAR file.\u00a0 This is nothing more than a ZIP archive with a standard directory layout, containing all of libraries and application-level dependencies needed at runtime.\u00a0 This format is mostly interoperable, and can be deployed to whichever server container you like, Tomcat or Jetty, JBoss or GlassFish, etc.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/embedded-java-server-300x229.png\"><img decoding=\"async\" class=\"alignright size-full wp-image-22889\" alt=\"embedded-java-server-300x229\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/embedded-java-server-300x229.png\" width=\"300\" height=\"229\" \/><\/a> However, there is another school of thought which completely turns this model on its head.\u00a0 In this approach, Java applications are packaged for command-line execution like any normal app.\u00a0 Rather than being deployed to a container, an embedded container is deployed within the application itself!<\/p>\n<p>This is par for the course with many languages.\u00a0 The <a href=\"https:\/\/www.djangoproject.com\/\" target=\"_blank\">Django<\/a> framework for Python includes a bundled server for development and testing, while <a href=\"http:\/\/rubyonrails.org\/\" target=\"_blank\">Ruby on Rails<\/a> comes with an embedded server that is used in production as well.\u00a0 The concept has even been around for awhile in Java, with <a href=\"http:\/\/www.eclipse.org\/jetty\/\" target=\"_blank\">Jetty<\/a> specializing in the embedded niche.\u00a0 However, this is far from the norm, and the de facto standard is still a WAR file that can be deployed to <a href=\"http:\/\/tomcat.apache.org\/\" target=\"_blank\">Tomcat<\/a>.<\/p>\n<p>The buzz is growing, though.\u00a0 At last year\u2019s\u00a0<a href=\"http:\/\/www.devnexus.com\/s\/index\" target=\"_blank\">DevNexus<\/a> conference, I went to a session by <a href=\"http:\/\/www.jamesward.com\/\" target=\"_blank\">James Ward<\/a>, who at that time was a \u201cdeveloper evangelist\u201d at <a href=\"http:\/\/java.heroku.com\/\" target=\"_blank\">Heroku<\/a>.\u00a0 Bundling your own container is the <a href=\"https:\/\/devcenter.heroku.com\/articles\/java\" target=\"_blank\">recommended<\/a> approach for deploying apps to Heroku\u2019s cloud-based platform, and James is a big <a href=\"http:\/\/www.jamesward.com\/2011\/08\/23\/war-less-java-web-apps\" target=\"_blank\">proponent<\/a>.<\/p>\n<p>His session was specifically about the <a href=\"http:\/\/www.playframework.com\/\" target=\"_blank\">Play<\/a> framework for Java and Scala, which embeds <a href=\"http:\/\/netty.io\/\" target=\"_blank\">Netty<\/a> in a manner similar to the Rails server.\u00a0 Unlike <a href=\"http:\/\/grails.org\/\">Grails<\/a>, which uses a Django-style server for development and then ships as a WAR file, Play is meant to use its own server all the way to production.\u00a0 James advocated this approach in all Java apps.<\/p>\n<h2>An embedded adventure<\/h2>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/hibernate-search-book-cover-242x300.jpg\"><img decoding=\"async\" class=\"alignleft size-full wp-image-22890\" alt=\"hibernate-search-book-cover-242x300\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/hibernate-search-book-cover-242x300.jpg\" width=\"176\" height=\"218\" \/><\/a><br \/>\nI had at least a sip of the Kool-Aid.\u00a0 When I started writing my book, <a href=\"http:\/\/www.packtpub.com\/hibernate-search-by-example\/book\" target=\"_blank\"><em>Hibernate Search by Example<\/em><\/a>, I wanted to keep its focus on Hibernate Search rather than any other frameworks or server issues.\u00a0 So I eschewed Spring, and wrote the book\u2019s example application using a vanilla Servlet 3.0 approach.<\/p>\n<p>I normally use Eclipse in my own development environment, and point it at a local Tomcat instance for testing web apps.\u00a0 However, I wanted to support readers who were more comfortable using IntelliJ, Netbeans, or no IDE at all.\u00a0 So I decided to have my build script <em>embed<\/em> a test server, so readers could run the examples without installing or configuring anything.<br \/>\n&nbsp;<\/p>\n<h3>Using an embedded server with Maven<\/h3>\n<p>My first goal was simply to launch a server from within my Maven build scripts, so the readers wouldn\u2019t have to install a server or integrate it into their IDE.\u00a0 I had seen this done before, and it was a simple matter of adding the <a href=\"http:\/\/wiki.eclipse.org\/Jetty\/Feature\/Jetty_Maven_Plugin\" target=\"_blank\">Jetty Maven Plugin<\/a> to a project\u2019s POM.\u00a0 Readers should be able to build the example application and launch it in one step, with the command:<\/p>\n<pre class=\" brush:bash\">mvn clean jetty:run<\/pre>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/built-by-maven-300x99.png\"><img decoding=\"async\" class=\"alignright size-full wp-image-22891\" alt=\"built-by-maven-300x99\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/built-by-maven-300x99.png\" width=\"300\" height=\"99\" \/><\/a>Eh, not so fast. You\u2019re supposed to be able to make changes to your static content, and see the changes immediately take effect while the server is running.\u00a0 However, I ran into errors about my files being locked. After wasting some time on research, I discovered that Jetty\u2019s default settings do not play nice with Windows file locking.\u00a0 This can be fixed by toggling one property in one <a href=\"http:\/\/wiki.eclipse.org\/Jetty\/Howto\/Deal_with_Locked_Windows_Files\" target=\"_blank\">config file<\/a>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>However, you have to crack open a Jetty JAR file to get a correct copy of this config file.\u00a0 First, you have to dig around your local Maven repo and figure out <em>which<\/em> JAR file to crack open (it turns out to be jetty-webapp rather than jetty-server).\u00a0 Once you get a copy of the webdefault.xml file and toggle the useFileMappedBuffer setting, you have to save your copy somewhere in your project, and update your Maven POM to look there rather than inside the Jetty JAR:<\/p>\n<pre class=\" brush:xml\">&lt;plugin&gt;\r\n   &lt;groupId&gt;org.mortbay.jetty&lt;\/groupId&gt;\r\n   &lt;artifactId&gt;jetty-maven-plugin&lt;\/artifactId&gt;\r\n   &lt;version&gt;8.1.7.v20120910&lt;\/version&gt;\r\n   &lt;configuration&gt;\r\n      &lt;webAppConfig&gt;\r\n         &lt;defaultsDescriptor&gt;${basedir}\/src\/main\/webapp\/WEB-INF\/webdefault.xml&lt;\/defaultsDescriptor&gt;\r\n      &lt;\/webAppConfig&gt;\r\n   &lt;\/configuration&gt;\r\n&lt;\/plugin&gt;<\/pre>\n<p>Okay\u2026 a little more hassle than I was expecting, but I can deal with this.<\/p>\n<h3>Using an embedded server with other build systems<\/h3>\n<p>I know that many Java developers hate Maven.\u00a0 So I wanted to provide a version of my book\u2019s example application built using Ant, to illustrate how the default concepts can be adapted.\u00a0 So, which line do I add to build.xml to make Ant use Jetty?<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/ant.png\"><img decoding=\"async\" class=\"alignleft size-full wp-image-22893\" alt=\"ant\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/ant.png\" width=\"200\" height=\"200\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/ant.png 200w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/ant-150x150.png 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/ant-100x100.png 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/ant-42x42.png 42w\" sizes=\"(max-width: 200px) 100vw, 200px\" \/><\/a>Eh, not so fast.\u00a0 There <em>is<\/em> <a href=\"http:\/\/wiki.eclipse.org\/Jetty\/Howto\/Use_Jetty_with_Ant\" target=\"_blank\">Ant integration for Jetty<\/a>, but it is even more cumbersome than Maven.\u00a0 Even if you are using a dependency-management system such as Ivy, your Ant script can\u2019t download and manage the embedded server for you.\u00a0 Instead, you have to download a full standalone Jetty server, and manually copy bits and pieces of it into your project.\u00a0 Who doesn\u2019t want 6 megs of executable binaries committed into source control?<\/p>\n<p>After you copy over the Jetty server JAR\u2019s, you need to manually add another <a href=\"http:\/\/repo1.maven.org\/maven2\/org\/mortbay\/jetty\/jetty-ant\/\" target=\"_blank\">JAR file<\/a> for the Ant integration.\u00a0 To my surprise, I discovered that the most recent supported version was Jetty 7, implementing the Servlet 2.5 spec that is almost <a href=\"http:\/\/en.wikipedia.org\/wiki\/Java_Servlet#History\" target=\"_blank\">eight years old<\/a>.<br \/>\n&nbsp;<br \/>\nI see that they finally added Jetty 8 last month, but that didn\u2019t help me when I was writing the book last autumn.\u00a0 I had to re-write this version of my example app for Servlet 2.5 instead of 3.0, and was starting to wonder if this was really worth it.<\/p>\n<h3>Using an embedded server from code<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Matrix-Code-150x150.jpg\"><img decoding=\"async\" class=\"alignright size-full wp-image-22894\" alt=\"Matrix-Code-150x150\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Matrix-Code-150x150.jpg\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Matrix-Code-150x150.jpg 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Matrix-Code-150x150-100x100.jpg 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/Matrix-Code-150x150-42x42.jpg 42w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a><\/h3>\n<p>This last chapter of my book talks about Hibernate Search applications running in a clustered server environment.\u00a0 The Maven plugin is purely single-instance, so I decided to write a small bootstrap class that would pro grammatically launch two Jetty instances on different ports.\u00a0 By structuring this class as a JUnit test, I could still have Maven launch it automatically like this:<br \/>\n&nbsp;<\/p>\n<pre class=\" brush:bash\">mvn clean compile war:exploded test<\/pre>\n<p>Eh, not so fast.\u00a0 My application\u2019s servlets, listeners, and RESTful services were not being registered at startup.\u00a0 After much more wasted research time, I discovered that there are <a href=\"http:\/\/stackoverflow.com\/questions\/6903539\/jetty-distribution-vs-hightide\" target=\"_blank\">different \u201cflavors\u201d<\/a> of Jetty available, with Servlet 3.0 features (such as annotations) enabled or disabled by default.<\/p>\n<p>To be honest, I still don\u2019t completely understand how to tell the difference between \u201chightide\u201d and \u201cnon-hightide\u201d.\u00a0 All I can tell you is that I had to add this hunk of code to my bootstrap class in order to make annotations work:<\/p>\n<pre class=\" brush:java\">...\r\nmasterContext.setConfigurations(\r\nnew Configuration[] {\r\nnew WebInfConfiguration(),\r\nnew WebXmlConfiguration(),\r\nnew MetaInfConfiguration(),\r\nnew FragmentConfiguration(),\r\nnew EnvConfiguration(),\r\nnew PlusConfiguration(),\r\nnew AnnotationConfiguration(),\r\nnew JettyWebXmlConfiguration(),\r\nnew TagLibConfiguration()\r\n}\r\n);\r\n...<\/pre>\n<p>So much simpler and more intuitive than dropping a WAR file in Tomcat\u2019s \/webapps folder, right?<\/p>\n<h3>Using an embedded server from the console and the cloud<\/h3>\n<p>With the book complete, I wanted a demo version of the example code pushed to\u00a0<a href=\"https:\/\/github.com\/steve-perkins\/hibernate-search-demo\" target=\"_blank\">GitHub<\/a> and deployed to <a href=\"http:\/\/hibernate-search-demo.herokuapp.com\/\" target=\"_blank\">Heroku<\/a>.\u00a0 Theoretically, Heroku can run any application that you can run locally from the command-line.\u00a0 If Heroku finds a Maven POM, it will run mvn clean package, and then execute whatever startup command you have placed in a script named Procfile.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/terminal-icon-150x150.png\"><img decoding=\"async\" class=\"alignleft size-full wp-image-22895\" alt=\"terminal-icon-150x150\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/terminal-icon-150x150.png\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/terminal-icon-150x150.png 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/terminal-icon-150x150-100x100.png 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/terminal-icon-150x150-42x42.png 42w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>My programmatic Jetty launcher worked fine within the context of a Maven run.\u00a0 However, Maven was managing my classpath dependencies at test time, and now I need Jetty available <em>without<\/em> that help.\u00a0 Heroku\u2019s <a href=\"http:\/\/www.jamesward.com\/2012\/02\/15\/webapp-runner-apache-tomcat-as-a-dependency\" target=\"_blank\">recommended approach<\/a>,\u00a0 used in their <a href=\"http:\/\/java.heroku.com\/\" target=\"_blank\">demo Java applications<\/a>, is to bundle your app with a one-file version of Tomcat.\u00a0 Awesome, I\u2019m more familiar with Tomcat anyway!<\/p>\n<p>Eh, not so fast.\u00a0 If your application expects database connections (or anything else) to be registered as JNDI resources, then you are on your own.\u00a0 Heroku\u2019s bundled Tomcat runner doesn\u2019t support JNDI setup.\u00a0 Hmm\u2026 maybe this is why Heroku\u2019s vanilla servlet demo doesn\u2019t really do anything, and why the only demo app that <em>does<\/em> do something is Spring-based instead.\u00a0 Now that I think about it, James Ward left Heroku to work for TypeSafe last year, and Heroku hasn\u2019t made a single update to their\u00a0<a href=\"http:\/\/java.heroku.com\/\" target=\"_blank\">Java site<\/a> since he left.\u00a0 Gulp.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/clouds-150x150.jpg\"><img decoding=\"async\" class=\"alignright size-full wp-image-22896\" alt=\"clouds-150x150\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/clouds-150x150.jpg\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/clouds-150x150.jpg 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/clouds-150x150-100x100.jpg 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/clouds-150x150-42x42.jpg 42w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a><br \/>\nDon\u2019t worry, because there is a similar one-file <a href=\"http:\/\/wiki.eclipse.org\/Jetty\/Howto\/Using_Jetty_Runner\" target=\"_blank\">Jetty Runner<\/a>, and it <em>does<\/em> let you pass JNDI settings as command-line parameters.\u00a0 Besides, we\u2019ve invested a lot of time solving all the problems with embedded Jetty already!<\/p>\n<p>Eh, still too fast.\u00a0 If you use JSTL taglibs in your JSP views (i.e. you live in the 21st century), then <a href=\"http:\/\/stackoverflow.com\/questions\/9333403\/web-app-started-by-jetty-runner-not-working-with-jstl-tags\" target=\"_blank\">Jetty Runner is a mess<\/a> that puts you in classpath hell.\u00a0 When running it from the command-line, you need to pass parameters to Java for:<\/p>\n<ol>\n<li>The Jetty Runner JAR file<\/li>\n<li>Your web application\u2019s WAR file (*)<\/li>\n<li>The exploded version of your WAR file, generated during the Maven build<\/li>\n<\/ol>\n<p>(*) You read that correctly.\u00a0 After all of this embedded nightmare, Heroku is <em>actually still using a WAR file<\/em>!!!<\/p>\n<p>My Heroku Profile ended up looking like this:<\/p>\n<pre class=\" brush:bash wrap-lines:false\">web: java $JAVA_OPTS -jar target\/dependency\/jetty-runner-8.1.7.v20120910.jar --lib target\/hibernate-search-demo-0.0.1-SNAPSHOT\/WEB-INF\/lib --port $PORT --jdbc org.apache.commons.dbcp.BasicDataSource \"url=jdbc:h2:mem:vaporware;DB_CLOSE_DELAY=-1\" \"jdbc\/vaporwareDB\" target\/*.war<\/pre>\n<p>There is more than one classloader at work here, and this allows the Jetty Runner to load the JSTL\/taglib stuff from its classpath rather than the web app\u2019s classpath.<\/p>\n<h2>Conclusion<\/h2>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/apple-pie-150x150.jpg\"><img decoding=\"async\" class=\"alignleft size-full wp-image-22897\" alt=\"apple-pie-150x150\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/apple-pie-150x150.jpg\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/apple-pie-150x150.jpg 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/apple-pie-150x150-100x100.jpg 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/apple-pie-150x150-42x42.jpg 42w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>There is nothing inherently wrong with the embedded server concept, when it is baked-in to a framework from the outset.\u00a0 Writing Play applications is a pleasure, and they are almost trivial to deploy on Heroku.\u00a0 At my day job, I use a Spring-based commerce package called <a href=\"http:\/\/www.hybris.com\/en\/\" target=\"_blank\">hybris<\/a>, whose extensive build system bundles a Tomcat server into your app.\u00a0 As long as you don\u2019t need to customize the build scripts too much, this works fine.<\/p>\n<p><a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/duct-tape-baby-150x150.jpg\"><img decoding=\"async\" class=\"alignright size-full wp-image-22898\" alt=\"duct-tape-baby-150x150\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/duct-tape-baby-150x150.jpg\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/duct-tape-baby-150x150.jpg 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/duct-tape-baby-150x150-100x100.jpg 100w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/03\/duct-tape-baby-150x150-42x42.jpg 42w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>On the other hand, the concept is just too fragile and brittle for wide general-purpose use.\u00a0 Duct taping an embedded server onto a normal Java application is pure pain.\u00a0 You might be able to cling to the safety of someone else\u2019s working example,\u00a0 but the moment your app does <em>anything<\/em> different, you are on your own to fix the breakage.\u00a0 Take my embedded adventure above, and contrast it with the \u201chassle\u201d of using Tomcat:<\/p>\n<ol>\n<li>Download Tomcat and unzip it somewhere<\/li>\n<li>Drop your WAR file in Tomcat\u2019s \/webapps subdirectory<\/li>\n<li>Start Tomcat<\/li>\n<\/ol>\n<p>The only real advantage I gained was the ability to run a demo on Heroku.\u00a0 However, Java support from cloud providers is improving every day.\u00a0 <a href=\"http:\/\/jelastic.com\/\" target=\"_blank\">Jelastic<\/a> lets you deploy normal WAR files to Tomcat 7 or GlassFish 3 right now.\u00a0 AppFog supports deployment to <a href=\"https:\/\/docs.appfog.com\/languages\/java\/spring\" target=\"_blank\">Tomcat 6<\/a>, with support for <a href=\"https:\/\/docs.appfog.com\/roadmap\" target=\"_blank\">Tomcat 7<\/a> coming soon.\u00a0 I suspect that in the not-so-distant future, the idea of <em>modifying<\/em> your apps for cloud deployment will be seen as an\u00a0anachronism.<\/p>\n<p>So in a nutshell, it depends on the framework you\u2019re using.\u00a0 If embedded servers are baked-in, then they can be very cool.\u00a0 If they are duct taped-on, then they can be horrible.\u00a0 If I were writing <em>Hibernate Search by Example<\/em> today, the example application build scripts would produce two things:\u00a0 a WAR file, and a Tomcat download link.<br \/>\n&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/steveperkins.net\/war-files-vs-embedded-servers\/\">WAR files vs. Java apps with embedded servers<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Steve Perkins at the <a href=\"http:\/\/steveperkins.net\/\">steveperkins.net<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for distribution is to bundle them as a WAR file.\u00a0 This is nothing more than a ZIP archive with a standard directory layout, containing all of libraries and application-level dependencies needed at runtime.\u00a0 &hellip;<\/p>\n","protected":false},"author":540,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-22798","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WAR files vs. Java apps with embedded servers<\/title>\n<meta name=\"description\" content=\"Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WAR files vs. Java apps with embedded servers\" \/>\n<meta property=\"og:description\" content=\"Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-03-17T11:00:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Steve Perkins\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/stevedperkins\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Steve Perkins\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html\"},\"author\":{\"name\":\"Steve Perkins\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/386fe0731aef53dd92368c548d68b79a\"},\"headline\":\"WAR files vs. Java apps with embedded servers\",\"datePublished\":\"2014-03-17T11:00:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html\"},\"wordCount\":1795,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html\",\"name\":\"WAR files vs. Java apps with embedded servers\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2014-03-17T11:00:34+00:00\",\"description\":\"Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/03\\\/war-files-vs-java-apps-with-embedded-servers.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"WAR files vs. Java apps with embedded servers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/386fe0731aef53dd92368c548d68b79a\",\"name\":\"Steve Perkins\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/33345302acac0352c123505f586e670dfcaeb99d195d5fd521c961640b283de9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/33345302acac0352c123505f586e670dfcaeb99d195d5fd521c961640b283de9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/33345302acac0352c123505f586e670dfcaeb99d195d5fd521c961640b283de9?s=96&d=mm&r=g\",\"caption\":\"Steve Perkins\"},\"description\":\"Steve Perkins is the author of \u201cHibernate Search by Example\u201d, and has over fifteen years of experience working with enterprise Java. Steve lives in Atlanta, GA, USA and currently works as a software architect at BetterCloud, where he writes software for the Google cloud ecosystem.\",\"sameAs\":[\"http:\\\/\\\/steveperkins.com\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/perkinssteve\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/stevedperkins\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/steve-perkins\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WAR files vs. Java apps with embedded servers","description":"Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html","og_locale":"en_US","og_type":"article","og_title":"WAR files vs. Java apps with embedded servers","og_description":"Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for","og_url":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-03-17T11:00:34+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Steve Perkins","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/stevedperkins","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Steve Perkins","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html"},"author":{"name":"Steve Perkins","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/386fe0731aef53dd92368c548d68b79a"},"headline":"WAR files vs. Java apps with embedded servers","datePublished":"2014-03-17T11:00:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html"},"wordCount":1795,"commentCount":6,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html","url":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html","name":"WAR files vs. Java apps with embedded servers","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2014-03-17T11:00:34+00:00","description":"Most server-side Java applications (e.g. web or service-oriented) are intended to run within a container.\u00a0 The traditional way to package these apps for","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2014\/03\/war-files-vs-java-apps-with-embedded-servers.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"WAR files vs. Java apps with embedded servers"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/386fe0731aef53dd92368c548d68b79a","name":"Steve Perkins","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/33345302acac0352c123505f586e670dfcaeb99d195d5fd521c961640b283de9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/33345302acac0352c123505f586e670dfcaeb99d195d5fd521c961640b283de9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/33345302acac0352c123505f586e670dfcaeb99d195d5fd521c961640b283de9?s=96&d=mm&r=g","caption":"Steve Perkins"},"description":"Steve Perkins is the author of \u201cHibernate Search by Example\u201d, and has over fifteen years of experience working with enterprise Java. Steve lives in Atlanta, GA, USA and currently works as a software architect at BetterCloud, where he writes software for the Google cloud ecosystem.","sameAs":["http:\/\/steveperkins.com\/","http:\/\/www.linkedin.com\/in\/perkinssteve","https:\/\/x.com\/https:\/\/twitter.com\/stevedperkins"],"url":"https:\/\/www.javacodegeeks.com\/author\/steve-perkins"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/22798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/540"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=22798"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/22798\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=22798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=22798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=22798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}