<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EclipseSource Blog &#187; war</title>
	<atom:link href="http://eclipsesource.com/blogs/tag/war/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipsesource.com/blogs</link>
	<description>Eclipse Equinox OSGi</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:54:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Executable WARs with Jetty</title>
		<link>http://eclipsesource.com/blogs/2009/10/02/executable-wars-with-jetty/</link>
		<comments>http://eclipsesource.com/blogs/2009/10/02/executable-wars-with-jetty/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 08:24:55 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[executable]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[servlet container]]></category>
		<category><![CDATA[war]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=3134</guid>
		<description><![CDATA[Today I want to talk about one of the younger members in the Eclipse family: Jetty. It is great to have such an interesting project on board and it is yet another example of how Eclipse has become more than just an IDE. What I wanted to with jetty was to create an executable, standalone [...]]]></description>
			<content:encoded><![CDATA[<p>Today I want to talk about one of the younger members in the Eclipse family: <a href="http://www.eclipse.org/jetty/">Jetty</a>. It is great to have such an interesting project on board and it is yet another example of how Eclipse has become more than just an IDE.</p>
<p>What I wanted to with jetty was to create an executable, standalone and self-contained WAR. I first encountered this concept in <a href="https://hudson.dev.java.net/">Hudson</a>. The hudson.war contains an embedded <a href="http://winstone.sourceforge.net/">Winstone servlet container</a>, which makes it possible to run the application by executing</p>
<pre>java -jar hudson.war</pre>
<p>This makes test driving the application really simple. The idea was to do the same with Jetty. Embedding the Jetty runtime in the war proved to be the easy part, as it was just a matter of declaring the jetty dependencies in the maven pom.xml.</p>
<p>The tricky part was telling jetty where to find the war-file to serve. My first try was to hardcode the filename, but that left a foul aftertaste. Finding a solution took quite some time, which is why I am posting this for future reference. This is the Main-Class used to bootstrap Jetty (adapted from the Wicket quickstart archetype):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.Connector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.Server</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.bio.SocketConnector</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.webapp.WebAppContext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Start <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    Server server <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Server<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    SocketConnector connector <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SocketConnector<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Set some timeout options to make debugging easier.</span>
    connector.<span style="color: #006633;">setMaxIdleTime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1000</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    connector.<span style="color: #006633;">setSoLingerTime</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    connector.<span style="color: #006633;">setPort</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8080</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server.<span style="color: #006633;">setConnectors</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Connector<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> connector <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    WebAppContext context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WebAppContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    context.<span style="color: #006633;">setServer</span><span style="color: #009900;">&#40;</span>server<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    context.<span style="color: #006633;">setContextPath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">ProtectionDomain</span> protectionDomain <span style="color: #339933;">=</span> Start.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getProtectionDomain</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">URL</span> location <span style="color: #339933;">=</span> protectionDomain.<span style="color: #006633;">getCodeSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getLocation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    context.<span style="color: #006633;">setWar</span><span style="color: #009900;">&#40;</span>location.<span style="color: #006633;">toExternalForm</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    server.<span style="color: #006633;">addHandler</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
      server.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">in</span>.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      server.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      server.<span style="color: #006633;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The interesting bit is the <code>getProtectionDomain()/getCodeSource()</code> part, which tells us the location of the war-file. That&#8217;s all there is to it. Presto, executable web-application powered by Jetty in jar.</p>
<p><em>Edit:</em> Added the import statements as per Tim&#8217;s suggestion.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/10/02/executable-wars-with-jetty/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Make p2, not war!</title>
		<link>http://eclipsesource.com/blogs/2009/03/17/make-p2-not-war/</link>
		<comments>http://eclipsesource.com/blogs/2009/03/17/make-p2-not-war/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 07:57:32 +0000</pubDate>
		<dc:creator>Manuel Woelker</dc:creator>
				<category><![CDATA[news]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[eclipsecon]]></category>
		<category><![CDATA[p2]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[war]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=889</guid>
		<description><![CDATA[I&#8217;ve been busy this weekend preparing one of the EclipseCon talks I will be doing together with Jordi. The background story to this talk is that we wanted to make it easier for users of Yoxos (and us of course) to deploy new versions of software along with relevant updates. Traditional &#8220;.war&#8221; deployments are very [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been busy this weekend preparing one of the EclipseCon talks I will be doing together with <a href="http://www.eclipsecon.org/2009/presenters#Jordi_B%EF%BF%BDhme_L%EF%BF%BDpez">Jordi</a>. The background story to this talk is that we wanted to make it easier for users of <a href="http://eclipsesource.com/en/products/yoxos-enterprise/">Yoxos</a> (and us of course) to deploy new versions of software along with relevant updates. Traditional &#8220;.war&#8221; deployments are very monolithic and inflexible. The deployment model is simplistic as you only have to support a single version (which may be advantageous to some). But for our needs, we needed a more modular approach to the problem. Since we are not in the business of reinventing circular transportation devices, we started looking at some existing technologies to get as much mileage as possible &#8211; so we can concentrate on other neat features.</p>
<p>With <a href="http://wiki.eclipse.org/Equinox_p2">Equinox p2</a>, Eclipse already has a powerful provisioning component that performs updates and installation of components&#8230; on the <strong>client side</strong>. Our goal was to leverage the effort that has gone into p2 and adapt the technology to work on the <strong>server side</strong>. The results are quite promising &#8211; with a small amount of effort, we could create a very flexible, modular and robust deployment mechanism. Has anyone else worked with p2 on the server side yet?</p>
<p>Find out more about the technical details at our talk &#8220;<a href="http://www.eclipsecon.org/2009/sessions?id=423">Down with WAR. Server-side deployment with p2</a>&#8221; at EclipseCon. Hope to see you there!</p>
<p><a href="http://www.eclipsecon.org/2009/presenters#Manuel_Woelker"><img title="Im speaking at EclipseCon" src="http://www.eclipsecon.org/2009/static/image/100x100_speaking.gif" alt="100x100 speaking Make p2, not war!"  /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/03/17/make-p2-not-war/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

