<?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>A Day At The Races</title>
	<atom:link href="http://blog.jetztgrad.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jetztgrad.net</link>
	<description>Programming was my first love, and it will be my last.</description>
	<lastBuildDate>Sat, 28 Apr 2012 15:27:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Introduction to YouDebug &#8211; Scriptable Java Debugger</title>
		<link>http://blog.jetztgrad.net/2012/04/introduction-to-youdebug-scriptable-java-debugger/</link>
		<comments>http://blog.jetztgrad.net/2012/04/introduction-to-youdebug-scriptable-java-debugger/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 15:20:27 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=396</guid>
		<description><![CDATA[I gave a short talk on YouDebug at the Mannheim Java User Group (Majug). YouDebug is a Java debugger developed by Kohsuke Kawaguchi, which can be scripted in Groovy. The slides are available here: The slides are available under the CreativeCommons license BY-NC-SA.]]></description>
			<content:encoded><![CDATA[<p>I gave a <a href="http://jug-mannheim.mixxt.de/networks/events/show_event.58016">short talk</a> on <a href="http://youdebug.kenai.com/">YouDebug</a> at the <a href="http://majug.de">Mannheim Java User Group</a> (Majug).<br />
YouDebug is a Java debugger developed by <a href="http://kohsuke.org/">Kohsuke Kawaguchi</a>, which can be scripted in <a href="http://groovy.codehaus.org/">Groovy</a>.</p>
<p>The slides are available here:</p>
<iframe src="http://www.slideshare.net/slideshow/embed_code/12727441" width="600" height="489" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><br/>
<p><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/"><img src="http://i.creativecommons.org/l/by-nc/3.0/88x31.png" alt="CC BY-NC-SA" /></a> The slides are available under the <a href="http://creativecommons.org/licenses/by-nc-sa/2.5/">CreativeCommons license BY-NC-SA</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2012/04/introduction-to-youdebug-scriptable-java-debugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Presentation: Introduction to Amazon Elastic Beanstalk</title>
		<link>http://blog.jetztgrad.net/2011/04/presentation-introduction-to-amazon-elastic-beanstalk/</link>
		<comments>http://blog.jetztgrad.net/2011/04/presentation-introduction-to-amazon-elastic-beanstalk/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 14:06:55 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[presentation]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=386</guid>
		<description><![CDATA[Lars Vogel gave a talk on Google AppEngine at the Mannheim Java User Group (Majug). Afterwards, I gave a short introduction to Amazon Elastic Beanstalk. The slides are available here: The slides are available under the CreativeCommons license BY-NC-SA.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vogella.de/">Lars Vogel</a> gave a <a href="http://jug-mannheim.mixxt.de/networks/events/show_event.35453">talk</a> on <a href="http://code.google.com/intl/de-DE/appengine/">Google AppEngine</a> at the <a href="http://majug.de">Mannheim Java User Group</a> (Majug). </p>
<p>Afterwards, I gave a short introduction to <a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a>. The slides are available here:</p>
<iframe src="http://www.slideshare.net/slideshow/embed_code/7703995" width="600" height="489" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><br/>
<p><a href="http://creativecommons.org/licenses/by-nc-sa/2.5/"><img src="http://i.creativecommons.org/l/by-nc/3.0/88x31.png" alt="CC BY-NC-SA" /></a> The slides are available under the <a href="http://creativecommons.org/licenses/by-nc-sa/2.5/">CreativeCommons license BY-NC-SA</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/04/presentation-introduction-to-amazon-elastic-beanstalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to customize an Amazon Elastic Beanstalk instance</title>
		<link>http://blog.jetztgrad.net/2011/02/how-to-customize-an-amazon-elastic-beanstalk-instance/</link>
		<comments>http://blog.jetztgrad.net/2011/02/how-to-customize-an-amazon-elastic-beanstalk-instance/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 02:24:57 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=345</guid>
		<description><![CDATA[The default Amazon Elastic Beanstalk AMI provides a Java-based application container with Apache Tomcat as the work horse. All you have to do is to deploy a standard Java WAR file containing your web application. But sometimes, the standard AMI does not provide everything. Maybe the Apache configuration needs to be tweaked or some package, [...]]]></description>
			<content:encoded><![CDATA[<p>The default <a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a> AMI  provides a Java-based application container with <a href="http://tomcat.apache.org/">Apache Tomcat</a> as the work horse. All you have to do is to deploy a standard <a href="http://en.wikipedia.org/wiki/WAR_(Sun_file_format)">Java WAR file</a> containing your web application.</p>
<p>But sometimes, the standard AMI does not provide everything. Maybe the Apache configuration needs to be tweaked or some package, e.g. a local <a href="http://memcached.org/">memcached</a> server, is missing. </p>
<p>Customizing the Beanstalk AMI is easy, there are only a few simple steps, which are outlined <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?ebs-creating-snapshot.html">here</a>.</p>
<p>First of all, start the AMI to be customized in the <a href="https://console.aws.amazon.com/ec2/home">AWS console</a>. <strong>Note</strong>: as described by <a href="https://forums.aws.amazon.com/profile.jspa?userID=159556">foremosttravel</a> in the <a href="https://forums.aws.amazon.com/thread.jspa?threadID=59380&#038;tstart=0">Beanstalk forum</a>, the instance should be started from the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a>, <em>NOT</em> the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">Beanstalk console</a>, as running the AMI within the Beanstalk environment may lead to it being terminated during the EBS snapshot, as it might fail to answer to the Beanstalk health checks.</p>
<p><strong>Preparation</strong></p>
<p>So here are the step by step instructions for the preparation:</p>
<ol>
<li>Go to the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a></li>
<li>Select region <em>US-East</em>, as Beanstalk is currently available only there</li>
<li>Click <em>Launch instance</em></li>
<li>Enter either <code>ami-100fff79</code> for the 64bit AMI or <code>ami-060fff6f</code> for the 32bit AMI (as of Feb 8th, 2011; these AMIs contain <a href="https://forums.aws.amazon.com/message.jspa?messageID=220954#220954">fixes</a> to preserve the original hostname and protocol, which are stripped by the load balancer)
<p><code></code><br />
<a href="http://blog.jetztgrad.net/wp-content/uploads/2011/02/start-instance.png"><img src="http://blog.jetztgrad.net/wp-content/uploads/2011/02/start-instance-1024x400.png" alt="Start instance from EC2 console" title="Start instance from EC2 console" width="1024" height="400" class="aligncenter size-large wp-image-347" /></a><br />
<code></code></p>
</li>
<li>Click <em>Select</em>, then <em>Continue</em>, until the step <strong>Create Key Pair</strong></li>
<li>Choose an existing key pair or create a new one. This will be used to access the running instance using SSH</li>
<li>In the next step, specify an appropriate security group, which allows SSH access, e.g. <code>SSH</code></li>
<li>Press continue and finally launch the instance</li>
<li>In the instance list, press the right mouse button over the instance and choose <em>Connect</em></li>
<li>Copy the SSH command line, adjust the path to your private key and connect to the instance using a SSH client.
<p><strong>Note</strong>: you need to connect as user <code>ec2-user</code>, <code>root</code> access can be obtained using the command <code>sudo su -</code>. See <a href="/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/">this blog post</a> for details on how to access the instance.</p>
<p><code></code><br />
<a href="http://blog.jetztgrad.net/wp-content/uploads/2011/02/connect-instance.png"><img src="http://blog.jetztgrad.net/wp-content/uploads/2011/02/connect-instance.png" alt="" title="connect-instance" width="602" height="509" class="aligncenter size-full wp-image-350" /></a><br />
<code></code></p>
</li>
</ol>
<p><strong>Customization</strong></p>
<p>Now we are free to customize the AMI&#8217;s files to our heart&#8217;s content.</p>
<p><strong>Note</strong>: As the AMI is running outside the Beanstalk environment, <code>Apache</code>, <code>Tomcat</code>, and <code>HostManager</code> (the software interface to Beanstalk), are not running, as they didn&#8217;t get the expected parameters, such as the path of the application to start. This doesn&#8217;t matter, as soon as we start the customized AMI in an Beanstalk environment, everything works again.</p>
<p>As a proof of concept, we change <code>HostManager</code>&#8216;s default index page (<code>/opt/elasticbeanstalk/srv/hostmanager/views/index.erb</code>) to contain the following HTML body:</p>
<p><code>&lt;body style=&quot;font-family:Verdana,Arial,Sans-serif;&quot;&gt;<br />
	&lt;div class=&quot;logo&quot;&gt;<br />
		&lt;img src=&quot;http://awsmedia.s3.amazonaws.com/logo_aws.gif&quot; /&gt;<br />
		&lt;h2&gt;Host Manager&lt;/h2&gt;<br />
		&lt;b&gt;Haz customization!&lt;/b&gt;<br />
	&lt;/div&gt;<br />
&lt;/body&gt;</code></p>
<p><strong>Note</strong>: when changing <code>HostManager</code> or the <code>Apache</code> configuration, please make sure, that <code>HostManager</code> still answers to Beanstalk requests on <code>/_hostmanager</code> and the application to health checks on <code>/</code>, otherwise the instance will be terminated and another will be started!</p>
<p><strong>Persisting changes</strong></p>
<p>Now that we are done,  we need to create an EBS snapshot to preserve our customizations. The AMI is <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?Concepts_BootFromEBS.html">EBS-backed</a>, so a snapshot can be used to register an AMI, which is based on the snapshot.</p>
<p>Again, here are the step by step instructions:</p>
<ol>
<li>Remove eveything you do not want to remain in the instance such as the bash history, SSH keys, &#8230;</li>
<li>Create an EBS snapshot, either from the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a> or the command line tools. See the <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?Tutorial_CreateImage.html">user guide</a> for details.
<li>You now have an AMI. See <em>Images &gt; AMI</em> on the left side of the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a> and choose <em>Owned By Me</em> in the AMI tab to view your newly create AMI. Note down the AMI id.</li>
</ol>
<p>If you want to make some more changes, keep the current instance running, while you test your changes from within Beanstalk. After a test drive (see below), make some more changes and create another image. Rinse and repeat until you are satisfied with the results. Don&#8217;t forget to clean up any unnecessary EBS snapshots and AMIs, as they cost actual money!</p>
<p><strong>Start customized instance in Beanstalk</strong></p>
<p>If you want to test-drive your customized AMI, you need to start an Beanstalk environment with the id of the customized AMI. There are two ways to perform this, via the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">Beanstalk console</a> or from the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line</a>.</p>
<p><em>Via Beanstalk console</em></p>
<ol>
<li>Go to the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">Beanstalk console</a></li>
<li>Create an environment</li>
<li>Wait for everything to be started so you can change the configuration</li>
<li>Adjust the AMI id as described in the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.managing.ec2.html">user guide</a></li>
<li>Restart the environment</li>
<li>Test your changes. In our example, we go to the changed <code>HostManager</code> index page at <a href="http://myenv.elasticbeanstalk.com/_hostmanager">http://myenv.elasticbeanstalk.com/_hostmanager</a><y/li>
</ol>
<p><em>Via command line</em></p>
<p>We use my <a href="http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/">simplified script</a> to start an Amazon Elastic Beanstalk application from command line. See <a href="http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/">here</a> for a detailed description. We can specify all parameters right from the start, so we do not need to wait for the initial start, before we can adjust the configuration.</p>
<ol>
<li><a href="https://gist.github.com/raw/808948/45cf55a10b9d6799bf21f7008fe10cba089e8cab/eb-create-app.sh">Download</a> the script from GitHub</li>
<li>Start an environment with the following command:<br />
<code>eb-create-app.sh -a myapp -i ami-be55a5d7 -t t1.micro -C 64 -e myenv -k mykeypair</code></p>
<p>Make sure to specify the id of your AMI as created above. Also don&#8217;t forget to specify a keypair, otherwise you won&#8217;t be able to log in using SSH. The name of the environment must be unique, as it is also used as CNAME (this can be overridden with <code>-c &lt;CNAME&gt;</code> though)
</li>
<li>Test your changes. In our example, we go to the changed <code>HostManager</code> index page at <a href="http://myenv.elasticbeanstalk.com/_hostmanager">http://myenv.elasticbeanstalk.com/_hostmanager</a><y/li>
</ol>
<p><strong>Outlook</strong></p>
<p>Have fun creating customized instances. Please leave feedback and/or a note in the comments, which describes your changes. I will try to change <code>HostManager</code> to run the <a href="http://eclipse.org/virgo/">Virgo</a> OSGi server instead of Tomcat, so stay tuned for the next installment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/02/how-to-customize-an-amazon-elastic-beanstalk-instance/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Script to start an Amazon Elastic Beanstalk application from command line</title>
		<link>http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/</link>
		<comments>http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 03:28:35 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=330</guid>
		<description><![CDATA[After playing around with Amazon Elastic Beanstalk, I started to explore the command line tools. Starting an Amazon Elastic Beanstalk application from the AWS console is easy and reasonably fast. The main problem is that you can&#8217;t currently provide additional settings such as the instance type (e.g. m1.small or t1.micro), a SSH key or application [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/">playing around</a> with Amazon Elastic Beanstalk, I started to explore the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line tools</a>.</p>
<p>Starting an <a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a> application from the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">AWS console</a> is easy and reasonably fast. The main problem is that you can&#8217;t currently provide additional settings such as the instance type (e.g. <code>m1.small</code> or <code>t1.micro</code>), a SSH key or application parameters. </p>
<p>After starting the application environment, it must be stopped again, before the configuration can be changed. This costs an instance hour but, more importantly, this procedure takes quite a while, as AWS must reconfigure the load balancer, auto-scaling group, start your instance(s), etc.</p>
<p>I created a <a href="https://gist.github.com/808948">script</a>, which can be used to start an application environment from the command line. The most important parameters can be set as command line parameters:</p>
<script src="http://gist.github.com/808950.js"></script>
<p>All you need is to install the Elastic Beanstalk <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line tools</a> and my <a href="https://gist.github.com/808948">script</a>.</p>
<p><b>Example</b></p>
<p>Starting an application <code>myapp</code> with environment <code>myenv</code> on a <code>m1.small</code> instance with SSH key <code>mysshkey</code> is as simple as:</p>
<p><code>eb-create-app.sh -a myapp -k mysshkey -e myenv -t m1.small -f 'mybucket/myapp.war'</code></p>
<p>Some notes:</p>
<ul>
<li>the application WAR file must already be uploaded to <a href="http://aws.amazon.com/s3/">S3</a>. The format of the file name (parameter <code>-f</code>) is <code>bucketname/key</code>. If the file name is not specified, Beanstalk will deploy the sample application</li>
<li>the environment can only be created, if the <code>CNAME</code> (which is identical to the environment name, if not specified with <code>-c</code>) is not already used. The <code>CNAME</code> is used as sub-domain under <code>elasticbeanstalk.com</code>. When creating an environment with name (and CNAME)  <code>myenv</code>, the full DNS name would be <a href="http://myenv.elasticbeanstalk.com">myenv.elasticbeanstalk.com</a></li>
<li>starting an environment will fail, if the SSH key name does not exist. You can look up the name of your SSH key in the <a href="https://console.aws.amazon.com/ec2/home">EC2 console</a></li>
</ul>
<p><strong>Elastic Beanstalk Parameters</strong></p>
<p>Elastic Beanstalk provides many parameters, which can be set. A full list can be obtained using <code>elastic-beanstalk-describe-configuration-settings</code>, also from the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-cli-overview.html">command line tools</a> (NOTE: <a href="https://forums.aws.amazon.com/thread.jspa?messageID=220042">fix required</a>!).</p>
<p>I created a list of all Elastic Beanstalk configuration options using <a href="https://gist.github.com/808962">another script</a> (requires ruby gem <a href="http://rubygems.org/gems/jazor">jazor</a>):</p>
<script src="http://gist.github.com/808968.js"></script>
<p>The <a href="https://gist.github.com/808972">long version</a> in JSON format is available <a href="https://gist.github.com/808972">here</a>.</p>
<p><strong>Final words</strong></p>
<p>Starting an application environment is easy and the command line tools help a lot. There are still some bugs, but I&#8217;m sure, the Beanstalk team will address them soon. The <a href="https://forums.aws.amazon.com/forum.jspa?forumID=86&#038;start=0">forum</a> is a great resource.</p>
<p>My next post will be about creating a customized Beanstalk AMI. Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/02/script-to-start-an-amazon-elastic-beanstalk-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dissecting an Amazon Elastic Beanstalk instance</title>
		<link>http://blog.jetztgrad.net/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/</link>
		<comments>http://blog.jetztgrad.net/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 13:15:41 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[beanstalk]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[infrastructure]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[osgi]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=295</guid>
		<description><![CDATA[Amazon Elastic Beanstalk provides a PaaS similar to Google AppEngine, bundling many of their existing offerings such as Elastic Compute Cloud (EC2), Simple Storage Service (S3), Simple Notification Service (SNS), Elastic Load Balancing, Auto Scaling, and monitoring using Cloud Watch into a simple to use service. Additionally, other Amazon services such as SimpleDB, Relational Database [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/elasticbeanstalk/">Amazon Elastic Beanstalk</a> provides a PaaS similar to <a href="http://code.google.com/appengine/">Google AppEngine</a>, bundling many of their existing offerings such as <a href="http://aws.amazon.com/de/ec2/">Elastic Compute Cloud</a> (EC2), <a href="http://aws.amazon.com/de/s3/">Simple Storage Service</a> (S3), <a href="http://aws.amazon.com/de/sns/">Simple Notification Service</a> (SNS), <a href="http://aws.amazon.com/de/elasticloadbalancing/">Elastic Load Balancing</a>, <a href="http://aws.amazon.com/autoscaling/">Auto Scaling</a>, and monitoring using <a href="http://aws.amazon.com/de/cloudwatch/">Cloud Watch</a> into a simple to use service. Additionally, other <a href="http://aws.amazon.com/">Amazon services</a> such as <a href="http://aws.amazon.com/de/simpledb/">SimpleDB</a>, <a href="http://aws.amazon.com/de/rds/">Relational Database Service</a> (RDS), <a href="http://aws.amazon.com/de/sqs/">Simple Queue Service</a> (SQS) may be used as well.</p>
<p>Currently, Elastic Beanstalk provides a Java-based application container with <a href="http://tomcat.apache.org/">Apache Tomcat</a> as the work horse. All you have to do is to deploy a standard <a href="http://en.wikipedia.org/wiki/WAR_(Sun_file_format)">Java WAR file</a> containing your web application.</p>
<p>Simply create a Java web application with <a href="http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html">Spring MVC</a>, <a href="http://grails.org/">Grails</a>, <a href="http://eclipsesource.com/blogs/2011/01/20/amazon-aws-beanstalk-and-eclipse-equinox/">OSGi</a>, <a href="http://eclipsesource.com/blogs/2011/01/20/amazon-aws-beanstalk-and-eclipse-equinox/">Eclipse RAP</a>, or any other of the numerous Java web frameworks and upload it using the <a href="https://console.aws.amazon.com/elasticbeanstalk/home">AWS web console</a>.</p>
<p>Additional containers for other platforms such as Ruby, Python or PHP may follow later, but as Tomcat hosts standard Java WAR files, anything with a Java implementation may be run. Ruby apps based on <a href="http://rubyonrails.org/">Rails</a> or <a href="http://rack.rubyforge.org/">Rack</a> using <a href="http://caldersphere.rubyforge.org/warbler/">Warbler</a> and <a href="http://jruby.org/">JRuby</a>, Python apps using <a href="http://www.jython.org/">Jython</a>, even PHP apps can be <a href="http://cameronstokes.com/2011/01/20/php-on-aws-elastic-beanstalk/">made to run</a> on Beanstalk.  </p>
<p>In this blog post, I&#8217;ll dive into the inner workings of a Beanstalk server instance and poke around its internals. I invite you to come along for the ride.</p>
<p><strong>Accessing your instance</strong><br />
The first step in dissecting a Beanstalk instance is <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.ec2connect.html">getting access via SSH</a>.<br />
In order to acces your running instance(s), you first need to configure the SSH key pair to be used:<br />
<div id="attachment_297" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.jetztgrad.net/wp-content/uploads/2011/01/config-server.png"><img src="http://blog.jetztgrad.net/wp-content/uploads/2011/01/config-server-300x204.png" alt="Configuration dialog in Elastic Beanstalk web console" title="config-server" width="300" height="204" class="size-medium wp-image-297" /></a><p class="wp-caption-text">Configuration dialog in Elastic Beanstalk web console</p></div></p>
<p>Enter the name of a key pair as configured in your <a href="https://console.aws.amazon.com/ec2/home#s=KeyPairs">EC2 web console</a>. See the <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?using-credentials.html">EC2 guide</a> and the description in the <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.managing.ec2.html">Elastic Beanstalk guide</a> for details on creating and configuring a key pair.</p>
<p>Setting the key pair requires a restart of your Beanstalk environment, which may take a couple of minutes.</p>
<p>Finally <a href="http://docs.amazonwebservices.com/elasticbeanstalk/latest/ug/index.html?using-features.ec2connect.html">look up your instance id</a> and get the instance&#8217;s hostname. Connecting to the server is now as simple as this:</p>
<p><code>ssh -i .ec2/mykeypair.pem ec2-user@ec2-184-72-134-2.compute-1.amazonaws.com</code></p>
<p>Please note, that you need to connect as user <code>ec2-user</code>, <code>root</code> access can be reached using the command</p>
<p><code>sudo su -</code></p>
<p><strong>Getting around your instance</strong><br />
The first steps are to collect some interessting facts. The instance uses a <a href="http://aws.amazon.com/amazon-linux-ami/">Amazon Linux AMI</a> (release 2010.11.1 (beta), <a href="https://gist.github.com/791135">README</a>). The AMI id for the ElasticBeanstalk-Tomcat6-32bit is <code>ami-7609f81f</code>, the kernel id is <code>aki-407d9529</code>. The instance is EBS-based and there is no ephemeral storage. Currently, Beanstalk is only available in the US East zone.</p>
<p><strong>Software</strong><br />
The <a href="https://gist.github.com/791133">process list</a> reveals: along with <a href="http://tomcat.apache.org/">Apache Tomcat</a>, Beanstalk uses the venerable <a href="http://httpd.apache.org/">Apache Web Server</a>. Additional software includes <a href="https://github.com/arya/bluepill">Bluepill</a> for basic process monitoring, and Amazons own HostManager (see below), which is run within a <a href="http://code.macournoyer.com/thin/">Thin</a> web server.</p>
<p><strong>Network setup</strong><br />
Elastic Beanstalk scales EC2 instances as needed. Therefore the first target is a load balancer provided by <a href="http://aws.amazon.com/de/elasticloadbalancing/">Elastic Load Balancing</a>. Each instance runs Apache as the front end on port <code>80</code>, with web request being reverse proxied into Tomcat on port <code>8080</code>. Requests for URI <code>/_hostmanager</code> are forwarded to HostManager on port <code>8999</code>.</p>
<p>CloudWatch performs health checks by periodically requesting the root page (URI <code>/</code>) of your application. Both health check URI and frequency are configurable. If an instance is no longer available or the load changes, CloudWatch starts or stops instances. </p>
<p><img src="http://media.amazonwebservices.com/blog/cb_env_1.png" alt="Application stack" /><br />
[Image from <a href="http://aws.typepad.com/aws/2011/01/aws-beanstalk-concepts.html">AWS Elastic Beanstalk Concepts</a> blog post]</p>
<p><strong>HostManager</strong><br />
Local instance management is performed by Amazons HostManager. HostManager is a Ruby application based on Rack and running in a <a href="http://code.macournoyer.com/thin/">Thin</a> server on port 8999. It receives requests on URI <code>/_hostmanager</code>.</p>
<p>Some examples from the access log:</p>
<p><code>72.21.217.96 (72.21.217.96) - - [21/Jan/2011:22:00:45 +0000] "POST /_hostmanager/tasks HTTP/1.1" 200 368 "-" "AWS ElasticBeanstalk Health Check/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:01:05 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:01:11 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:01:36 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:01:42 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
72.21.217.96 (72.21.217.96) - - [21/Jan/2011:22:01:46 +0000] "POST /_hostmanager/tasks HTTP/1.1" 200 368 "-" "AWS ElasticBeanstalk Health Check/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:02:07 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:02:13 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.223.61.43 (10.223.61.43) - - [21/Jan/2011:22:02:38 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
10.122.19.154 (10.122.19.154) - - [21/Jan/2011:22:02:44 +0000] "GET /_hostmanager/healthcheck HTTP/1.1" 200 90 "-" "ELB-HealthChecker/1.0"<br />
72.21.217.96 (72.21.217.96) - - [21/Jan/2011:22:02:47 +0000] "POST /_hostmanager/tasks HTTP/1.1" 200 368 "-" "AWS ElasticBeanstalk Health Check/1.0"<br />
</code></p>
<p><strong>Files</strong><br />
HostManager is installed in <code>/opt/elasticbeanstalk/srv/hostmanager</code>. A file list can be found <a href="https://gist.github.com/791104">here</a>. <code>/opt/elasticbeanstalk/lib</code> also contains a full Ruby 1.9.1 installation.</p>
<p>Some log files can be found at <code>/opt/elasticbeanstalk/var/</code>:</p>
<p><code>/opt/elasticbeanstalk<br />
/opt/elasticbeanstalk/var<br />
/opt/elasticbeanstalk/var/state<br />
/opt/elasticbeanstalk/var/state/hostmanager.pid<br />
/opt/elasticbeanstalk/var/state/healthcheck<br />
/opt/elasticbeanstalk/var/tmp<br />
/opt/elasticbeanstalk/var/log<br />
/opt/elasticbeanstalk/var/log/LogDirectoryMonitor.log<br />
/opt/elasticbeanstalk/var/log/DaemonManager.log<br />
/opt/elasticbeanstalk/var/log/bluepill.log<br />
/opt/elasticbeanstalk/var/log/hostmanager.log<br />
/opt/elasticbeanstalk/var/log/ApplicationHealthcheck.log<br />
/opt/elasticbeanstalk/var/log/CatalinaLogMonitor.log<br />
</code></p>
<p><strong>Final words</strong><br />
That&#8217;s all for today&#8217;s blog post. Further posts will take a closer look at HostManager and deployment including the application setup sequence.</p>
<p>I&#8217;m looking forward to any feedback and additional information.</p>
<p>Maybe we can even hack HostManager to accept other application containers, e.g. for OSGi applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/01/dissecting-an-amazon-elastic-beanstalk-instance/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Introducing groovyx.osgi: OSGi DSL for Groovy</title>
		<link>http://blog.jetztgrad.net/2011/01/groovyx-osgi-osgi-dsl-for-groovy/</link>
		<comments>http://blog.jetztgrad.net/2011/01/groovyx-osgi-osgi-dsl-for-groovy/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 10:40:46 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[groovy]]></category>
		<category><![CDATA[osgi]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=270</guid>
		<description><![CDATA[Programming for and in an OSGi environment is sometimes hard. Getting started is hard as well. groovyx.osgi helps both setting up an OSGi environment and simplifies programming by providing support for easy access to OSGi services, etc. Setting up an OSGi environment Setting up an OSGi environment is hard work: you have to download an [...]]]></description>
			<content:encoded><![CDATA[<p>Programming for and in an OSGi environment is sometimes hard. Getting started is hard as well. <code>groovyx.osgi</code> helps both setting up an OSGi environment and simplifies programming by providing support for easy access to OSGi services, etc.</p>
<p><strong>Setting up an OSGi environment</strong></p>
<p>Setting up an OSGi environment is hard work: you have to download an OSGi  implementation (usually <a href="http://felix.apache.org/">Apache Felix</a> or <a href="http://eclipse.org/equinox/">Eclipse Equinox</a>, but there are <a href="/osgi-stuff/osgi-runtime-comparison/">others</a> as well). Then there are many dependencies to download. There is an excellent tool, which simplifies the startup part: <a href="http://paxrunner.ops4j.org/">Pax Runner</a>. Pax Runner can resolve dependencies from URLs or Maven repositories and start the OSGi framework.</p>
<p>One problem remains: you need to download Pax Runner and the configuration is a (set of) static text file(s). To simplify things and allow scripting in the &#8220;recipes&#8221;, the module <a href="https://github.com/jetztgradnet/groovyx-osgi/tree/master/groovyx-osgi-runtime">groovyx.osgi.runtime</a> (<a href="https://github.com/jetztgradnet/groovyx-osgi/tree/master/groovyx-osgi-runtime#readme">README</a>) provides a nice Groovy DSL for creating and starting an OSGi framework.</p>
<p>Features:</p>
<ul>
<li>provision bundles from filesystem, web, Maven repositories</li>
<li>run Eclipse Equinox or Apache Felix OSGi runtimes</li>
<li>flexible Groovy DSL, fully programmable</li>
<li>lifecycle callback closures</li>
</ul>
<p>The dependency resolution code is derived from <a href="http://grails.org/">Grails</a> and was written by <a href="http://twitter.com/graemerocher">Graeme Rocher</a>.</p>
<p>Simple example:</p>
<script src="http://gist.github.com/742786.js"></script>
<p>A more complete example including automatic download of dependencies can be found <a href="https://gist.github.com/784209">here</a>. Another <a href="https://gist.github.com/784220">example</a> provisions an entire OSGi environment including Apache Felix WebConsole on port 8081.</p>
<p><strong>Simplified Programming Model</strong></p>
<p>The OSGi programming model is based on services (or micro-services, as Peter Kriens <a href="http://www.osgi.org/blog/2010/03/services.html">likes to call</a> them), which are accessed via the <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html">BundleContext</a>. Services are dynamic, they can come and go any time during the lifetime of an OSGi application. This is both a strength, as an application can be extended or updated without application shutdown, and a weakness, as it requires careful handling of service dynamics.</p>
<p>Looking up and using a service requires a lot of boiler plate code. A simple example in Java:</p>
<script src="http://gist.github.com/784237.js"></script>
<p>The equivalent Groovy code using module <code>groovyx.osgi</code> looks like this:</p>
<script src="http://gist.github.com/784239.js"></script>
<p>The <code>groovyx.osgi</code> module (<a href="https://github.com/jetztgradnet/groovyx-osgi/tree/master/groovyx-osgi#readme">README</a>) contains helper classes to make OSGi programming easier. This package was inspired by <a href="https://github.com/weiglewilczek/scalamodules/wiki">ScalaModules</a>.</p>
<p>Features:</p>
<ul>
<li>simplifies working with OSGi service registry</li>
<li>safe access to OSGi services, without fear for OSGi dynamics</li>
<li>Service finder DSL</li>
<li>OSGi service filter DSL.</li>
</ul>
<p>The filter support is derived from the <a href="http://code.google.com/p/filter4osgi/">filter4osgi</a> project and was contributed by <a href="http://hamletdarcy.blogspot.com/">Hamlet D’Arcy</a>.</p>
<p>An overview on basic usage of Groovy with OSGi can be found at the <a href="http://groovy.codehaus.org/OSGi+and+Groovy">Groovy Homepage</a>.</p>
<p><strong>Source code and binaries</strong></p>
<p><code>groovyx.osgi</code> and <code>groovyx.osgi.runtime</code> are released under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0 license</a>. The code is available at <a href="https://github.com/jetztgradnet/groovyx-osgi/">GitHub</a>.</p>
<p>You can either <a href="https://github.com/jetztgradnet/groovyx-osgi/archives/master">download</a> <code>groovyx.osgi</code> and <code>groovyx.osgi.runtime</code> <code>0.1</code> from GitHub or install it using <a href="http://groovy.codehaus.org/Grape">Grape</a>, <a href="http://ant.apache.org/ivy/">Ivy</a>, or <a href="http://maven.apache.org/">Maven</a> from the Maven repository at <a href="https://github.com/jetztgradnet/repository/raw/master">https://github.com/jetztgradnet/repository/raw/master</a>. </p>
<p>A simple example using <a href="http://groovy.codehaus.org/Grape">Grape</a>:</p>
<script src="http://gist.github.com/784211.js"></script>
<p>This script is executable with nothing but Groovy (>= 1.7.5) installed.</p>
<p><strong>Roadmap</strong></p>
<p>The following items are planned for the next releases:</p>
<p><code>groovyx.osgi</code></p>
<ul>
<li>simplified service registration <code>MyObject.registerService(Map, Closure)</code></li>
<li>simplified use of <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/util/tracker/ServiceTracker.html">ServiceTracker</a>, <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/service/cm/ManagedService.html">ManagedService</a>, and <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/service/cm/ManagedServiceFactory.html">ManagedServiceFactory</a></li>
<li>improve docs</li>
</ul>
<p><code>groovyx.osgi.runtime</code></p>
<ul>
<li>add support for pre-defined provisioning profiles</li>
<li>add support for OSGi <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/service/cm/ConfigurationAdmin.html">ConfigurationAdmin</a></li>
<li>improve handling of external OSGi runtimes</li>
<li>improve docs</li>
</ul>
<p><a href="http://grails.org/plugin/osgi">Grails OSGi plugin</a></p>
<ul>
<li>use <code>groovyx.osgi</code> and <code>groovyx.osgi.runtime</code></li>
<li>migrate usage of <a href="http://www.springsource.org/osgi">Spring DM</a> to its successor Eclipse <a href="http://www.eclipse.org/gemini/blueprint/">Gemini Blueprint</a> and <a href="http://www.eclipse.org/gemini/web/">Gemini Web</a></li>
<li>add support for easy access to OSGi services</li>
</ul>
<p><strong>Final thoughts</strong></p>
<p>OSGi provides no silver bullet for modularization, but it greatly helps, once you wrapped your head around bundles, services and dependencies. It&#8217;s not always an easy road, but there are many helpful tools and <a href="http://www.osgi.org/Planet/Feed">people</a> out there. I hope, <code>groovyx.osgi</code> can help you to create great applications. Have fun playing in your OSGi sandbox and don&#8217;t forget to send me your thoughts. Any feedback is greatly appreciated, either in the comments or <a href="https://github.com/jetztgradnet/groovyx-osgi/issues">open a issue</a> at GitHub.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2011/01/groovyx-osgi-osgi-dsl-for-groovy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Grails on OSGi: Released Grails OSGi plugin 0.2.1</title>
		<link>http://blog.jetztgrad.net/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2-1/</link>
		<comments>http://blog.jetztgrad.net/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2-1/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 22:27:41 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=263</guid>
		<description><![CDATA[I just released a small update for the OSGi plugin, which fixes dependency resolution for Spring DM. Thanks to lemnitram and Klaus Baumecker for reporting it. Spring DM 2.0 is currently only available as snapshot release (2.0.0.M1). The jars used to be available from other repositories (e.g. SpringSource Enterprise Bundle Repository (EBR)), but they have [...]]]></description>
			<content:encoded><![CDATA[<p>I just released a small update for the <a href="http://grails.org/plugin/osgi">OSGi plugin</a>, which <a href="http://github.com/jetztgradnet/grails-osgi-plugin/issues/issue/15">fixes dependency resolution</a> for <a href="http://www.springsource.org/osgi">Spring DM</a>.</p>
<p>Thanks to <a href="http://github.com/jetztgradnet/grails-osgi-plugin/issues/issue/15">lemnitram</a> and <a href="http://blog.jetztgrad.net/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2/#comment-323">Klaus Baumecker</a> for reporting it.</p>
<p>Spring DM 2.0 is currently only available as snapshot release (2.0.0.M1). The jars used to be available from other repositories (e.g. <a href="http://www.springsource.com/repository/">SpringSource Enterprise Bundle Repository</a> (EBR)), but they have vanished, so I needed to add the Spring Milestone Repository.</p>
<p>For installation and usage of the plugin see me previous <a href="/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2/">blog post</a> and the <a href="http://grails.org/plugin/osgi">docs</a>.</p>
<p>Spring DM has been <a href="http://www.eclipse.org/proposals/gemini/">donated</a> to the <a href="http://www.eclipse.org/">Eclipse Foundation</a> by <a href="http://www.springsource.com/">SpringSource</a>, where it will be part of the <a href="http://eclipse.org/gemini/blueprint/">Gemini Blueprint</a> and <a href="http://eclipse.org/gemini/web/">Gemini Web</a> projects. This means, that Spring DM 2.0 will never be released, so the <a href="http://grails.org/plugin/osgi">OSGi Plugin</a> needs to be <a href="http://eclipse.org/gemini/blueprint/documentation/migration/">ported</a> to use <a href="http://eclipse.org/gemini/blueprint/">Gemini Blueprint</a> and <a href="http://eclipse.org/gemini/web/">Gemini Web</a> instead. This will happen in the 0.3 release. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2-1/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Grails on OSGi: Released Grails OSGi plugin 0.2</title>
		<link>http://blog.jetztgrad.net/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2/</link>
		<comments>http://blog.jetztgrad.net/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 00:08:32 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=245</guid>
		<description><![CDATA[I just released version 0.2 of my OSGi plugin for Grails. The OSGi plugin is released under the Apache License 2.0. The Grails OSGi plugin adds support to package and run a Grails application as an OSGi bundle. The bundle(s) may be run in an ad hoc assembled OSGi container or deployed to an external [...]]]></description>
			<content:encoded><![CDATA[<p>I just released version 0.2 of my <a href="http://grails.org/plugin/osgi">OSGi plugin</a> for Grails. The OSGi plugin is released under the <a href="http://apache.org/licenses/LICENSE-2.0.txt">Apache License 2.0</a>.</p>
<p>The Grails OSGi plugin adds support to package and run a Grails application as an OSGi bundle. The bundle(s) may be run in an ad hoc assembled OSGi container or deployed to an external OSGi app server such as <a href="http://www.springsource.org/dmserver">SpringSource DM Server</a>, <a href="http://eclipse.org/virgo/">Eclipse Virgo</a>, or <a href="http://karaf.apache.org/">Apache Karaf</a>. </p>
<p>See my <a href="http://blog.jetztgrad.net/grails-on-osgi/">blog series</a> for earlier thoughts and information for running a Grails application in an OSGi environment as well as concepts of and basic information on OSGi.</p>
<p>This post and the following installments of the series will show how to use the plugin and present some examples.</p>
<p><b>Installation</b></p>
<p>Simply call <code>grails install-plugin osgi</code> to install the OSGi plugin.</p>
<p><b>Usage</b></p>
<p><i>Creating an OSGi bundle from the Grails application</i></p>
<p><code>grails bundle</code><br />
<code>grails prod bundle</code></p>
<p><i>Running the bundle</i></p>
<p><code>grails run-bundle</code><br />
<code>grails prod run-bundle</code></p>
<p>The application can be accessed at <a href="http://localhost:8080/myapp-0.1/">http://localhost:8080/myapp-0.1/</a>.</p>
<p><b>Note</b>: at first start the OSGi runtime is assembled, which may take some time, while Ivy is downloading the Internet&#8230;</p>
<p><b>Note</b>: if the bundle exists, it won&#8217;t be re-created automatically after changes. So for now use parameter <code>-forceBundle</code> after changing something in the Grails app: <code>grails run-bundle -forceBundle</code>.</p>
<p><b>Accessing the bundle context</b></p>
<p>The <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html">bundle context</a> is the primary interface to the OSGi framework. It can be used to find and register services and interact the environment.</p>
<p>The bundle context is available from Grails&#8217; parent ApplicationContext as bean <code>bundleContext</code>. It can be injected into all Spring-managed beans, i.e. all Grails artifacts, like Controllers, Services, etc.</p>
<p>In order to get a reference to the BundleContext, an artifact needs to define a reference with the name <code>bundleContext</code>.</p>
<p><b>Example</b>: controller accessing bundle context</p>
<pre>
class OsgiTestController {
    def bundleContext
    def index = {
        def bundles = []
        if (bundleContext) {
            bundles = bundleContext.bundles
        }
        else {
            flash.message = "bundleContext NOT available"
        }
        [ bundles: bundles ]
    }
}
</pre>
<p><b>Changes since version 0.1</b></p>
<ul>
<li>using Spring DM instead of Pax Web as Web extender</li>
<li>updated Apache Felix WebConsole</li>
<li> replaced (most) dependencies from bundle by OSGi bundles from the <a href="http://www.springsource.com/repository">SpringSource Enterprise Bundle Repository</a> (EBR)</li>
<li>provide access to OSGi <code>BundleContext</code> to artifacts (controllers, services, &#8230;) via Spring injection as bean <code>bundleContext</code></li>
</ul>
<p><b>How it works</b></p>
<p>In order to be a valid OSGi bundle, the application is war&#8217;ed and provided with the necessary bundle manifest headers (see <code>scripts/_Events.groovy</code> for details).<br />
The bundle can be created using <code>grails bundle</code>.  </p>
<p>The OSGi runtime is assembled in the <code>target/osgi</code> directory and uses the <a href="http://eclipse.org/equinox/">Eclipse Equinox</a> OSGi framework, <a href="http://www.springsource.org/osgi">Spring DM</a>.</p>
<p>In the current version, most libraries from </code>WEB-INF/lib</code> are replaced by equivalent OSGi bundles from the <a href="http://www.springsource.com/repository/">SpringSource Enterprise Bundle Repository</a> (EBR). Only Hibernate and Grails libs retain in the bundle. </p>
<p>Grails jars already are OSGi bundles, but they cannot currently be installed cleanly in a OSGi container, as they contain circular dependencies and some other dependencies can not be satisfied (e.g. the Radeox library used by the Grails Wiki is no longer maintained, but it shouldn't be referenced from the Grails runtime anyway...). </p>
<p>There are bundles for Hibernate but due to a bug (possibly in Equinox), Hibernate Cache can not be resolved by the Spring ORM module (see "SPR-7003":https://issues.springsource.org/browse/SPR-7003 for a description of this problem).</p>
<p>The parent ApplicationContext has been replaced in </code>web.xml</code> by an OSGi-aware variant: <a href="http://static.springsource.org/osgi/snapshot-site/apidocs/org/springframework/osgi/web/context/support/OsgiBundleXmlWebApplicationContext.html">OsgiBundleXmlWebApplicationContext</a>. It knows how to <a href="http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/service-registry.html#service-registry:export">export</a> and <a href="http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/service-registry.html#service-registry:refs">import</a> OSGi services as/from Spring beans through Spring XML files. These features are currently hidden, but they will be exposed in the next version of the OSGi plugin and made easier through the BeanBuilder DSL and the <a href="http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/service-registry.html">OSGi namespace</a>.</p>
<p><b>Roadmap</b></p>
<ul>
<li>make bundle generation configurable (e.g. include/exclude dependencies, ...)</li>
<li>make OSGi runtime created by <code>grails run-bundle</code> and <code>grails assemble-osgi-runtime</code> configurable</li>
<li>support auto-reloading of changed artifacts</li>
<li>create sub class of GrailsApplicationContext, which implements <a href="http://static.springsource.org/osgi/snapshot-site/apidocs/org/springframework/osgi/context/ConfigurableOsgiBundleApplicationContext.html">ConfigurableOsgiBundleApplicationContext</a></li>
<li>export main Grails beans and application context as OSGi service</li>
<li>export services as OSGi service (via <code>static expose = 'osgi'</code>)</li>
<li>implement deployment to <a href="http://www.springsource.org/dmserver">SpringSource DM Server</a> or its successor <a href="http://eclipse.org/virgo/">Eclipse Virgo</a>
</li>
<li>implement deployment to <a href="http://karaf.apache.org/">Apache Karaf</a></li>
<li>Spring DM has been donated to Eclipse, so it should be replaced by its successor <a href="http://eclipse.org/gemini/">Eclipse Gemini</a></li>
</ul>
<p><b>Getting around the OSGi runtime</b></p>
<p><i>Web Console</i></p>
<p>The "Felix Web Management Console":http://felix.apache.org/site/apache-felix-web-console.html provides excellent insight into the inner workings. It can be accessed at <a href="http://localhost:8081/system/console/">http://localhost:8081/system/console/</a> with user "admin" and password "admin" (<b>Note</b>: the web console runs on a different port!).</p>
<p><i>Shell Console</i></p>
<p>The command <code>grails run-bundle</code> drops the user in the Equinox Shell (press <code>RETURN</code> if you don't see the <code>osgi></code> prompt). Running <code>grails run-bundle -remoteConsole [port]</code> opens a console with telnet access on the specified port or on port <code>8023</code>, if omitted. Only a single user can use the console at any time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2010/07/grails-on-osgi-released-grails-osgi-plugin-0-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Released Grails Spy plugin 0.2</title>
		<link>http://blog.jetztgrad.net/2010/07/released-grails-spy-plugin-0-2/</link>
		<comments>http://blog.jetztgrad.net/2010/07/released-grails-spy-plugin-0-2/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 21:50:40 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[spy]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=225</guid>
		<description><![CDATA[I just released version 0.2 of my Grails Spy plugin. About The Grails Spy plugin provides some views to inspect Grails internals such as the Spring application context(s), artefacts, etc. As most of the beans of the Grails WebApplicationContext are constructed at runtime with the help of a BeanBuilder, there is no Spring xml file [...]]]></description>
			<content:encoded><![CDATA[<p>I just released version 0.2 of my <a href="http://grails.org">Grails</a> <a href="http://grails.org/plugin/spy">Spy plugin</a>.</p>
<p><b>About</b></p>
<p>The Grails Spy plugin provides some views to inspect Grails internals such as the Spring application context(s), artefacts, etc.</p>
<p>As most of the beans of the Grails WebApplicationContext are constructed at runtime with the help of a BeanBuilder, there is no Spring xml file with bean definitions.</p>
<p>In order to browse the dynamic bean definitions, Grails Spy can be used to watch into an application’s guts.</p>
<p><b>Installation</b></p>
<pre>grails install-plugin spy</pre>
<p><b>Usage</b></p>
<p>Simply install the plugin, enable the Spy controller for the <code>dev</code> environment and run <code>grails run-app</code>. Then browse to <a href="http://localhost:8080/yourapp/spy">http://localhost:8080/yourapp/spy</a> and enjoy.</p>
<p><b>Changes</b></p>
<ul>
<li>For security reasons the Spy controller must now be enabled in Config.groovy:
<pre>
grails.plugins.spy.enabled = true
</pre>
<p>	The plugin can be enabled or disabled individually for each environment. Example:</p>
<pre>
environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
	grails.plugins.spy.enabled = true
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }
}
</pre>
</li>
<li>&apos;inspect&apos; is now the default action for the spy controller, so it can be called as <a href="http://localhost:8080/yourapp/spy">http://localhost:8080/yourapp/spy</a> instead of <a href="http://localhost:8080/yourapp/spy/inspect">http://localhost:8080/yourapp/spy/inspect</a></li>
</ul>
<p><b>License</b></p>
<p>The Spy plugin is released under the <a href="http://apache.org/licenses/LICENSE-2.0.txt">Apache License 2.0</a>.</p>
<p><b>Source code and Issues</b></p>
<p>The source code is hosted at <a href="http://github.com/jetztgradnet/grails-spy-plugin">GitHub</a>, issues can be reported <a href="http://github.com/jetztgradnet/grails-spy-plugin/issues">here</a>.</p>
<p><b>Screenshots</b></p>
<p>Eye-candy you say? See below:</p>
<p><b>GrailsSpy: GrailsApplication</b></p>
<p><a href="/wp-content/uploads/2010/01/GrailsSpy-GrailsApplication.png"><img src="/wp-content/uploads/2010/01/GrailsSpy-GrailsApplication-65x300.png" alt="" title="GrailsSpy: GrailsApplication" width="65" height="300" class="aligncenter size-medium wp-image-197" /></a></p>
<p><b>GrailsSpy: ApplicationContext view</b></p>
<p><a href="/wp-content/uploads/2010/01/GrailsSpy-MainApplicationContext.png"><img src="/wp-content/uploads/2010/01/GrailsSpy-MainApplicationContext-141x300.png" alt="" title="GrailsSpy: ApplicationContext view" width="141" height="300" class="aligncenter size-medium wp-image-199" /></a></p>
<p><b>GrailsSpy: bean view</b></p>
<p><a href="/wp-content/uploads/2010/01/GrailsSpy-jspViewResolver.png"><img src="/wp-content/uploads/2010/01/GrailsSpy-jspViewResolver-300x242.png" alt="" title="GrailsSpy: bean view" width="300" height="242" class="aligncenter size-medium wp-image-198" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2010/07/released-grails-spy-plugin-0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails Spy plugin mentioned in Grails podcast</title>
		<link>http://blog.jetztgrad.net/2010/01/grails-spy-plugin-mentioned-in-grails-podcast/</link>
		<comments>http://blog.jetztgrad.net/2010/01/grails-spy-plugin-mentioned-in-grails-podcast/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 00:14:22 +0000</pubDate>
		<dc:creator>Wolfgang Schell</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://blog.jetztgrad.net/?p=218</guid>
		<description><![CDATA[My Grails Spy plugin was mentioned in the episode 103 (at 0:18:30) of Grails Podcast. Thanks, Glen and Sven!]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://grails.org/plugin/spy">Grails Spy plugin</a> was mentioned in the <a href="http://www.grailspodcast.com/blog/id/550">episode 103</a> (at 0:18:30) of <a href="http://www.grailspodcast.com/">Grails Podcast</a>. Thanks, <a href="http://blogs.bytecode.com.au/glen/">Glen</a> and <a href="http://hansamann.wordpress.com/">Sven</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jetztgrad.net/2010/01/grails-spy-plugin-mentioned-in-grails-podcast/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

