title: TomEE embedded/bundle with single application
body: <p>I'm currently exploring building a webapp which is bound to a TomEE server, i.e. it either runs as the sole (additional) application within a TomEE or has a TomEE embedded. The webapp should support servlets and JSPs (basically we'd like to use Struts2 here).</p>
  
  <p>I tried a couple of options which all had several problems:</p>
  
  <p><strong>Option 1</strong>: Use the Maven-Shade-Plugin to bundle our application and tomee-embedded as described here: <a href="http://www.tomitribe.com/blog/2015/03/50-shades-of-tomee/" rel="nofollow">http://www.tomitribe.com/blog/2015/03/50-shades-of-tomee/</a></p>
  
  <p>Problems:</p>
  
  <p>1) Deploying the bundled application only works with the 7.x version via the <code>--as-war</code> option but 7.x is not yet production ready and I couldn't find any planned release dates</p>
  
  <p>2) Deploying JAXRS webservices worked fine but servlets didn't e.g. web.xml was not picked up, there were classloading issues etc. </p>
  
  <p><strong>Option 2</strong>: Use the TomEE-Maven-Plugin to build a zip which contains tomee as well as our webapp.</p>
  
  <p>Problems:</p>
  
  <p>1) This only works with plugin version 7.x (not production ready yet), but this should not affect the resulting build (which is based on TomEE 1.7.2)</p>
  
  <p>2) There are library conflicts since TomEE might load some libs that are also provided by the application (in a different version). </p>
  
  <p>Since the application is tied to the server and vice versa it should be ok to place all libraries into to TomEE's lib folder which works by pointing the Maven plugin to the folder the dependencies are downloaded to. This works but there's no conflict resolution, i.e. the libs are just copied to the target folder.</p>
  
  <p>I now could manually configure the plugin to remove each conflicting artifact but as the application and thus the number of potentially conflicting libraries grows this can become quite cumbersome.</p>
  
  <p><strong>Option 3</strong>: Like option 2 but without using the TomEE-Maven-Plugin.</p>
  
  <p>I guess it should be possible to use a pre-packaged TomEE and some Maven plugins to build a distributable zip which would solve problem no. 1 but problem no. 2 - which is the bigger one - still remains: handling all the dependencies manually would be cumbersome.
  <br><br><br>
  So finally, the question is: how should I build that application? </p>
  
  <p>I'd prefer option 1 but I couldn't yet find any documentation/example/tutorial on how to make that work. </p>
  
  <p>Options 2 and 3 would be ok as well but I'd need some way to have Maven resolve the dependency conflicts without requiring me to check each dependency, especially the transitive ones.</p>