<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Technocratic Dilemmas</title>
	<atom:link href="http://thecarlhall.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecarlhall.wordpress.com</link>
	<description>Another blog about things that technerds run into.</description>
	<lastBuildDate>Sun, 29 Jan 2012 16:45:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thecarlhall.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Technocratic Dilemmas</title>
		<link>http://thecarlhall.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thecarlhall.wordpress.com/osd.xml" title="Technocratic Dilemmas" />
	<atom:link rel='hub' href='http://thecarlhall.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Understanding the &#8216;unresolved constraint&#8217;, &#8216;missing resource&#8217; message from Apache Felix</title>
		<link>http://thecarlhall.wordpress.com/2012/01/19/understanding-the-unresolved-constraint-missing-resource-message-from-apache-felix/</link>
		<comments>http://thecarlhall.wordpress.com/2012/01/19/understanding-the-unresolved-constraint-missing-resource-message-from-apache-felix/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 18:40:19 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[osgi]]></category>
		<category><![CDATA[bundles]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[dependency resolution]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=271</guid>
		<description><![CDATA[It&#8217;s pretty common while developing an OSGi bundle that your imports and exports won&#8217;t quite match what you need or what exists in the server you&#8217;re deploying to. This can show up as NoClassDefFoundError, ClassNotFoundException or as log output in &#8230; <a href="http://thecarlhall.wordpress.com/2012/01/19/understanding-the-unresolved-constraint-missing-resource-message-from-apache-felix/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=271&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s pretty common while developing an OSGi bundle that your imports and exports won&#8217;t quite match what you need or what exists in the server you&#8217;re deploying to. This can show up as <code>NoClassDefFoundError</code>, <code>ClassNotFoundException</code> or as log output in a stacktrace from bundle resolution. Hall, Pauls, McCullough and Savage did a great job of covering NCDFE and CNFE in <a href="http://www.manning.com/hall/" title="OSGi In Action" target="_blank">&#8220;OSGi In Action&#8221;</a> (chapter 8), let&#8217;s take a look at figuring out what the bundle resolution stacktrace is telling us. <em>(I make nothing from the sales of &#8220;OSGi In Action&#8221; and suggest it to anyone interested in OSGi.)</em></p>
<p>Just like learning to read the stacktrace from an exception in Java is key to debugging, so is true about the dependency resolution messages from an OSGi container. Below is the output from <a title="Apache Felix" href="http://felix.apache.org/site/index.html" target="_blank">Apache Felix</a> when it encountered a missing dependency required by a bundle:</p>
<p><pre class="brush: plain;">
ERROR: Bundle org.sakaiproject.nakamura.webconsole.solr [124]: Error starting slinginstall:org.sakaiproject.nakamura.webconsole.solr-1.2-SNAPSHOT.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle org.sakaiproject.nakamura.webconsole.solr [124]: Unable to resolve 124.0: missing requirement [124.0] package; (package=org.apache.solr.client.solrj) [caused by: Unable to resolve 84.0: missing requirement [84.0] package; (package=org.sakaiproject.nakamura.api.lite) [caused by: Unable to resolve 86.0: missing requirement [86.0] package; (&amp;(package=com.google.common.collect)(version&gt;=9.0.0)(!(version&gt;=10.0.0)))]])
org.osgi.framework.BundleException: Unresolved constraint in bundle org.sakaiproject.nakamura.webconsole.solr [124]: Unable to resolve 124.0: missing requirement [124.0] package; (package=org.apache.solr.client.solrj) [caused by: Unable to resolve 84.0: missing requirement [84.0] package; (package=org.sakaiproject.nakamura.api.lite) [caused by: Unable to resolve 86.0: missing requirement [86.0] package; (&amp;(package=com.google.common.collect)(version&gt;=9.0.0)(!(version&gt;=10.0.0)))]]
    at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3443)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1727)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1156)
    at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
    at java.lang.Thread.run(Thread.java:619)
</pre></p>
<p>What you have here is a stacktrace with a lengthy message. The important part of the stacktrace for us <em>is</em> the message.</p>
<p><pre class="brush: plain;">
ERROR: Bundle org.sakaiproject.nakamura.webconsole.solr [124]: Error starting slinginstall:org.sakaiproject.nakamura.webconsole.solr-1.2-SNAPSHOT.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle org.sakaiproject.nakamura.webconsole.solr [124]: Unable to resolve 124.0: missing requirement [124.0] package; (package=org.apache.solr.client.solrj) [caused by: Unable to resolve 84.0: missing requirement [84.0] package; (package=org.sakaiproject.nakamura.api.lite) [caused by: Unable to resolve 86.0: missing requirement [86.0] package; (&amp;(package=com.google.common.collect)(version&gt;=9.0.0)(!(version&gt;=10.0.0)))]])
</pre></p>
<p>This message is pretty simple but the structure is common for nastier messages (i.e. deeper resolution paths before failure). Let&#8217;s pull it apart to see what&#8217;s happening in there.</p>
<p><pre class="brush: plain;">ERROR: Bundle org.sakaiproject.nakamura.webconsole.solr [124]: Error starting slinginstall:org.sakaiproject.nakamura.webconsole.solr-1.2-SNAPSHOT.jar</pre></p>
<p>This very first part tells us that an error occurred while trying to load the <code>org.sakaiproject.nakamura.webconsole.solr</code>bundle. Nice start, but not quite the crux of the matter. Let&#8217;s keep reading.</p>
<p><pre class="brush: plain;">org.osgi.framework.BundleException: Unresolved constraint in bundle org.sakaiproject.nakamura.webconsole.solr [124]: Unable to resolve 124.0: missing requirement [124.0] package; (package=org.apache.solr.client.solrj) [caused by: Unable to resolve 84.0: missing requirement [84.0] package; (package=org.sakaiproject.nakamura.api.lite) [caused by: Unable to resolve 86.0: missing requirement [86.0] package; (&amp;(package=com.google.common.collect)(version&gt;=9.0.0)(!(version&gt;=10.0.0)))]])</pre></p>
<p>Phew, that&#8217;s a lot of text! This is the heart of what we need though, so let&#8217;s break it down to make more sense of it.</p>
<p><pre class="brush: plain;">
(
    org.osgi.framework.BundleException: Unresolved constraint in bundle org.sakaiproject.nakamura.webconsole.solr [124]: Unable to resolve 124.0: missing requirement [124.0] package; (package=org.apache.solr.client.solrj)
        [
            caused by: Unable to resolve 84.0: missing requirement [84.0] package; (package=org.sakaiproject.nakamura.api.lite)
            [
                 caused by: Unable to resolve 86.0: missing requirement [86.0] package; (&amp;(package=com.google.common.collect)(version&gt;=9.0.0)(!(version&gt;=10.0.0)))
            ]
        ]
)
</pre></p>
<h3>What are those <code>[number]</code>s in the message?</h3>
<p>The numbers in the message tell us the bundle ID on the server.</p>
<table>
<tbody>
<tr>
<th>Unresolved Package Name</th>
<th>Bundle ID Where Resolution Failed</th>
</tr>
<tr>
<td>org.apache.solr.client.solrj</td>
<td>124</td>
</tr>
<tr>
<td>org.sakaiproject.nakamura.api.lite</td>
<td>84</td>
</tr>
<tr>
<td>com.google.common.collect</td>
<td>86</td>
</tr>
</tbody>
</table>
<p>Once you pull apart the message it becomes more obvious that it has structure and meaning! The structure of the message tells us that bundle 124 depends on a package from bundle 84 which depends on a package from bundle 86 which is unable to resolve <code>com.google.common.collect;version=[9.0.0, 10.0.0)</code>. The innermost/very last message tells us the root of the problem; the dependency resolver was unable to find <code>com.google.common.collect</code> at <code>version=[9.0.0, 10.0.0)</code>. Now we have somewhere to start digging.</p>
<h3>How To Fix This</h3>
<p>I suggest one of the following steps:</p>
<ol>
<li>Add a bundle that exports the missing package with a version that matches the required version</li>
<li>Change the version to match an exported package already on the server</li>
</ol>
<p>In this particular environment, <code>com.google.common.collect;version=10.0.0</code> is what our server has deployed. The descriptor above specifically blocks any version not in the 9.x.x range. We generate the OSGi manifest by using the <a title="Maven Bundle Plugin" href="http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html" target="_blank">Maven Bundle Plugin</a> which uses the BND tool to generate the manifest. In BND version &gt; 2.1.0, the <a title="macro for versions" href="http://www.aqute.biz/Bnd/Versioning" target="_blank">macro for versions</a> was changed. Our solution has ranged from rolling back to bnd version=2.1.0 <strong>OR</strong> <a title="define the macro differently" href="http://davidvaleri.wordpress.com/2011/04/07/secrets-of-the-felix-bundle-plug-in-macros-revealed/" target="_blank">define the macro differently</a>. The results are the same; the version segment in the manifest header becomes <code>com.google.common.collect;version&gt;=9.0.0</code> which finds our bundle of <code>com.google.common.collect;version=10.0.0</code>.</p>
<p><em><br />
<h3>Notes about environment</h3>
<p>The above message and stacktrace originated from a Sakai OAE environment which is built on Apache Sling and thusly Apache Felix. We use an artifact ID that is the root package of the bundle (org.sakaiproject.nakamura.webconsole.solr). This has the side effect that our bundle names look like package names in the message but gives a very clear naming convention.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=271&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2012/01/19/understanding-the-unresolved-constraint-missing-resource-message-from-apache-felix/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>Using pygraphviz to plot OSGi bundle dependencies</title>
		<link>http://thecarlhall.wordpress.com/2011/09/05/using-pygraphviz-to-plot-osgi-bundle-dependencies/</link>
		<comments>http://thecarlhall.wordpress.com/2011/09/05/using-pygraphviz-to-plot-osgi-bundle-dependencies/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 16:46:48 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=253</guid>
		<description><![CDATA[I&#8217;ve been working on an OSGi project for the last few years. As with any project, evolutionary changes will eventually require some cleanup. As new bundles have been added over time, the graph of dependencies is starting to get unwieldy &#8230; <a href="http://thecarlhall.wordpress.com/2011/09/05/using-pygraphviz-to-plot-osgi-bundle-dependencies/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=253&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on an OSGi project for the last few years. As with any project, evolutionary changes will eventually require some cleanup. As new bundles have been added over time, the graph of dependencies is starting to get unwieldy in places. Even with good management of these dependencies, a nice visual layout of things can really help you see how your bundles are interconnected and give you the power to start separating some connections if you graph starts to hit cyclical dependencies.</p>
<p>I drove around a few different visual tools in Eclipse (<a title="PDE visualization tool" href="http://www.eclipse.org/pde/incubator/dependency-visualization/" target="_blank">PDE visualization tool</a>, m2eclipse dependency graph) but needed something that would narrow the view to just my project. I not only wanted to see what things my bundles depend on in the project but I wanted to see what depends on a given bundle.</p>
<p>This was my first project with pygraphviz but after I figured out which way the grain runs, I was able to give it a basic graph of my project and generate the diagrams I wanted. I finally let pygraphviz handle the graph traversing and things got better (less code, faster results).</p>
<p>Since I wanted to analyze the runtime dependencies of my server, I installed the <a title="Felix Remote Shell" href="http://felix.apache.org/site/apache-felix-remote-shell.html" target="_blank">Felix Remote Shell</a> bundle along with the <a title="Felix Shell" href="http://felix.apache.org/site/apache-felix-shell.html" target="_blank">Felix Shell</a> bundle to allow remote connections to management functionality. With these in place, I was able to connect via telnet and query for package level information to build my graph.</p>
<p>Using the code below, I was able to generate a graph of the entire project (successors) and a graph for each bundle in the graph (predecessors and successors). Some sample images are below the source code. Eventually I&#8217;ll add saving and opening of dot files to allow for analysis without a running server.</p>
<p><pre class="brush: python;">
#! /usr/bin/env python
import re
from sets import Set
import os
import pygraphviz as pgv
import sys
import telnetlib

# [   1] [Active     ] [   15] org.sakaiproject.nakamura.messaging (0.11.0.SNAPSHOT)
bundle_from_ps = re.compile('^\[\s*(?P&lt;bundle_id&gt;\d+)\]\s\[.+\]\s(?P&lt;bundle_name&gt;.+)\s')

# org.sakaiproject.nakamura.api.solr; version=0.0.0 -&gt; org.sakaiproject.nakamura.solr [11]
bundle_from_req = re.compile('^.*-\&gt; (?P&lt;bundle_name&gt;.*) \[(?P&lt;bundle_id&gt;.*)\]$')

def get_sakai_bundles():
    &quot;&quot;&quot;Get a list of bundles that are create as part of Sakai OAE.
    Returns a dictionary of dict[bundle_name] = bundle_id.
    &quot;&quot;&quot;
    tn = telnetlib.Telnet('localhost', '6666')
    tn.write('ps -s\nexit\n')
    lines = [line for line in tn.read_all().split('\r\n') if 'org.sakaiproject' in line]

    bundles = {}
    for line in lines:
        m = bundle_from_ps.match(line)
        bundles[m.group('bundle_name')] = m.group('bundle_id')
    return bundles

def get_package_reqs(bundle_id):
    &quot;&quot;&quot;Gets the requirements (imports) for a given bundle.
    Returns a dictionary of dict[bundle_name] = bundle_id.

    Keyword arguments:
    bundle_id -- Bundle ID returned by the server in the output of
                 get_sakai_bundles()
    &quot;&quot;&quot;
    tn = telnetlib.Telnet('localhost', '6666')
    tn.write('inspect package requirement %s\nexit\n' % (bundle_id))
    lines = [line for line in tn.read_all().split('\r\n') if line.startswith('org.sakaiproject') and line.endswith(']')]

    reqs = {}
    for line in lines:
        m = bundle_from_req.match(line)
        reqs[m.group('bundle_name')] = m.group('bundle_id')
    return reqs

def build_bundle_graph():
    &quot;&quot;&quot;Build a graph_attr (nodes, edges) representing the connectivity
    within Sakai bundles
    &quot;&quot;&quot;
    sakai_bundles = get_sakai_bundles()
    bundles = {}
    for b_name, b_id in sakai_bundles.items():
        reqs = get_package_reqs(b_id)
        bundles[b_name] = reqs.keys()
    return bundles

def draw_subgraph(name, graph, filename, successors = True):
    &quot;&quot;&quot;Draw (write to disk) a subgraph that starts with or ends with
    the specified node.

    Keyword arguments:
    name -- name of the node to focus on
    graph -- graph of paths between bundles
    filename -- filename to write subgraph to
    successors -- whether to lookup successors or predecessors
    &quot;&quot;&quot;
    if successors:
        nbunch = graph.successors(name)
    else:
        nbunch = graph.predecessors(name)

    if nbunch:
        nbunch.append(name)
        subgraph = graph.subgraph(nbunch)
        subgraph.layout(prog = 'dot')
        subgraph.draw('graphviz/%s' % filename)

def main():
    if not os.path.isdir('graphviz'):
        os.mkdir('graphviz')

    bundles_graph = build_bundle_graph()

    # print the whole graph
    graph = pgv.AGraph(data = bundles_graph, directed = True)
    graph.layout(prog = 'dot')
    graph.draw('graphviz/org.sakaiproject.nakamura.png')

    for b_name, reqs in bundles_graph.items():
        draw_subgraph(b_name, graph, '%s.png' % b_name)
        draw_subgraph(b_name, graph, '%s-pred.png' % b_name, False)

if __name__ == '__main__':
    main()
</pre></p>
<div id="attachment_260" class="wp-caption alignnone" style="width: 650px"><a href="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura.png"><img class="size-full wp-image-260" title="org.sakaiproject.nakamura" src="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura.png?w=640&#038;h=107" alt="Sakai OAE Bundle Dependency Graph" width="640" height="107" /></a><p class="wp-caption-text">Sakai OAE Bundle Dependency Graph</p></div>
<div id="attachment_261" class="wp-caption alignnone" style="width: 650px"><a href="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura-solr-pred.png"><img class="size-full wp-image-261" title="org.sakaiproject.nakamura.solr-pred" src="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura-solr-pred.png?w=640&#038;h=180" alt="Sakai OAE Solr Bundle Predecessors" width="640" height="180" /></a><p class="wp-caption-text">Sakai OAE Solr Bundle Predecessors</p></div>
<div id="attachment_262" class="wp-caption alignnone" style="width: 650px"><a href="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura-presence.png"><img class="size-full wp-image-262" title="org.sakaiproject.nakamura.presence" src="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura-presence.png?w=640&#038;h=264" alt="Sakai OAE Presence Bundle Successors" width="640" height="264" /></a><p class="wp-caption-text">Sakai OAE Presence Bundle Successors</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/253/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=253&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2011/09/05/using-pygraphviz-to-plot-osgi-bundle-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>

		<media:content url="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura.png" medium="image">
			<media:title type="html">org.sakaiproject.nakamura</media:title>
		</media:content>

		<media:content url="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura-solr-pred.png" medium="image">
			<media:title type="html">org.sakaiproject.nakamura.solr-pred</media:title>
		</media:content>

		<media:content url="http://thecarlhall.files.wordpress.com/2011/09/org-sakaiproject-nakamura-presence.png" medium="image">
			<media:title type="html">org.sakaiproject.nakamura.presence</media:title>
		</media:content>
	</item>
		<item>
		<title>Committer Status on Apache Sling</title>
		<link>http://thecarlhall.wordpress.com/2011/02/16/committer-status-on-apache-sling/</link>
		<comments>http://thecarlhall.wordpress.com/2011/02/16/committer-status-on-apache-sling/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 05:58:09 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=246</guid>
		<description><![CDATA[I woke up this morning to the fantastic news that I&#8217;ve been offered committer status on Apache Sling! I graciously and excitedly accepted the opportunity to become an Apache committer. The various points of processing are in motion, so expect &#8230; <a href="http://thecarlhall.wordpress.com/2011/02/16/committer-status-on-apache-sling/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=246&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I woke up this morning to the fantastic news that I&#8217;ve been offered committer status on Apache Sling! I graciously and excitedly accepted the opportunity to become an Apache committer.<br />
The various points of processing are in motion, so expect to see more Sling posts from me as I get ramped up into being a more productive member of Apache Sling.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/246/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=246&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2011/02/16/committer-status-on-apache-sling/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>Basics of OSGi and Declarative Services</title>
		<link>http://thecarlhall.wordpress.com/2011/02/09/basics-of-osgi-and-declarative-services/</link>
		<comments>http://thecarlhall.wordpress.com/2011/02/09/basics-of-osgi-and-declarative-services/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 02:32:37 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=240</guid>
		<description><![CDATA[This is a slide deck for a talk I gave at the Sakai 2010 conference in lovely Denver, Colorado. The title to the talk was &#8220;Using OSGi in Nakamura&#8221; which was my original intention, but after reviewing the slides I &#8230; <a href="http://thecarlhall.wordpress.com/2011/02/09/basics-of-osgi-and-declarative-services/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=240&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a slide deck for a talk I gave at the Sakai 2010 conference in lovely Denver, Colorado. The title to the talk was &#8220;Using OSGi in Nakamura&#8221; which was my original intention, but after reviewing the slides I seemed to have given a talk about the basics of OSGi. Good information under a wrong marquee.</p>
<p>No matter the intention, I found today that I needed to refer to the slides for setting up an activator, so I&#8217;m reposting it here to give myself and hopefully others faster access. Be on the lookout for a repeat performance of this presentation at the Sakai 2011 conference in Los Angeles. I might even try to show it around a bit once the European conference is announced.</p>
<iframe src='http://www.slideshare.net/slideshow/embed_code/4518794' width='640' height='525'></iframe>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=240&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2011/02/09/basics-of-osgi-and-declarative-services/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>When To Immediately Activate An OSGi Component</title>
		<link>http://thecarlhall.wordpress.com/2011/02/04/when-to-immediately-activate-an-osgi-component/</link>
		<comments>http://thecarlhall.wordpress.com/2011/02/04/when-to-immediately-activate-an-osgi-component/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 05:16:13 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[osgi]]></category>
		<category><![CDATA[services]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=229</guid>
		<description><![CDATA[OSGi has a fantastic feature for immediate components [1] and delayed components [2]. This allows components to delay their possibly expensive activation until the component is first accessed. At the very least it allows the OSGi platform to consume resources as &#8230; <a href="http://thecarlhall.wordpress.com/2011/02/04/when-to-immediately-activate-an-osgi-component/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=229&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OSGi has a fantastic feature for immediate components <a href="#1_osgi"><sup>[1]</sup></a> and delayed components <a href="#2_osgi"><sup>[2]</sup></a>. This allows components to delay their possibly expensive activation until the component is first accessed. At the very least it allows the OSGi platform to consume resources as needed. No sense is sucking up those server resources for something that can wait.</p>
<p>As developers start their adventure into OSGi, I&#8217;ve noticed a pattern creeping up that I&#8217;m not sure folks are aware of: j<em>ust because you like your component doesn&#8217;t mean it needs to start immediately.</em> Unless your component has something it needs to do before other components can do their work, there&#8217;s little need to start a component immediately. A lot of times, the work can be moved into the bundle activator or is fine being delayed.</p>
<p>People often see that a component does <em>something</em> in its activation method and assume it should start immediately. The questions to ask yourself are:</p>
<ul>
<li>Will the things that need to use this component have a reference to it?<br />
<em>Yes? Delayed activation.</em></li>
<li>Before activation, will functionality be missing that should be available as soon as possible?<br />
<em>Yes? Immediate activation.</em></li>
<li>Can something else do the job of activating the component at a later time?<br />
<em>Yes? Delayed activation.</em></li>
</ul>
<p>Registering with an external service, such as JMS, is a perfect scenario for an immediate component. If the JMS service were in OSGi, declarative services could do the work of making sure service trackers know your component exists, but OSGi has no jurisdiction over external resources. Binding to a JMS topic requires manual interaction and therefore should happen by way of immediate component activation.</p>
<p>Getting and setting of properties is not a case for immediate component activation. Neither is because the service is referenced by something else.</p>
<p>When using declarative services, a reference to your not-yet-started component will be given to anything that has said it wants to collect an interface you implement. This requires no effort on the part of the service being referenced and thusly does not require the referenced service to be activated immediately. Fret not! On first access of this service by any consumer the service will get activated.</p>
<p>OSGi has not been the fastest thing for me to learn but understanding the nuances of little things like this really helps me understand why it is a good approach at decoupled services and modular software construction.</p>
<p><a name="1_osgi"><sub>1. OSGi compendium spec version 4.2, section 112.2.2</sub></a><br />
<a name="2_osgi"><sub>2. OSGi compendium spec version 4.2, section 112.2.3</sub></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/229/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=229&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2011/02/04/when-to-immediately-activate-an-osgi-component/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>LDAP Authentication &amp; Authorization Dissected and Digested</title>
		<link>http://thecarlhall.wordpress.com/2011/01/04/ldap-authentication-authorization-dissected-and-digested/</link>
		<comments>http://thecarlhall.wordpress.com/2011/01/04/ldap-authentication-authorization-dissected-and-digested/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 05:32:59 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[ldap]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=83</guid>
		<description><![CDATA[LDAP is one of those things that I&#8217;ve integrated with a few times but never put enough energy into to really get the details or understand it much.&#160; There&#8217;s always been someone I can bounce questions off of and thankfully &#8230; <a href="http://thecarlhall.wordpress.com/2011/01/04/ldap-authentication-authorization-dissected-and-digested/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=83&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>LDAP is one of those things that I&#8217;ve integrated with a few times but never put enough energy into to really get the details or understand it much.&nbsp; There&#8217;s always been someone I can bounce questions off of and thankfully those people were available again as I started working out the details of performing LDAP authentication.</p>
<p>The steps below are general enough to be used by anyone and will hopefully shed some light into the steps performed in LDAP authentication. &nbsp;The process below also includes some steps for authorization.</p>
<p>
<h3>Authentication</h3>
</p>
<p><em>1. &nbsp;Get a connection to the LDAP server.</em><br />
With the host and port for the LDAP server, create a connection to it. &nbsp;This can be &nbsp;a simple direct connection or a pooled connection. &nbsp;If more than a basic test, it is best to use a pooled connection. &nbsp;Log and fail if a connection cannot be created.</p>
<p><em>2. &nbsp;Bind as the application user.</em><br />
Bind the connection to the application user. &nbsp;This user should have enough permissions to search the area of LDAP where users are located. &nbsp;This user may also have permissions to search for things outside of the users area (groups, authorization). &nbsp;Log and fail if the application user cannot bind.</p>
<p><em>3. &nbsp;Search for the DN (distinguished name) of the user to be authenticated.</em><br />
This is where we verify the username is valid. &nbsp;This does not authenticate the user but simply makes sure the requested username exists in the system. &nbsp;Log and fail if the user&#8217;s DN is not found.</p>
<p><em>4. &nbsp;Bind as user to be authenticated using DN from step 3.</em><br />
Now for the moment of truth. &nbsp;Bind to the connection using the DN found in step 3 and the password supplied by the user. &nbsp;Log and fail if unable to bind using the user&#8217;s DN and password.</p>
<p>
<h3>Authorization</h3>
</p>
<p><em>5. &nbsp;Re-bind as application user.</em><br />
To check the authorization of a user, we need to read attributes from the user&#8217;s account.  To do this, we need to re-bind as the application user.</p>
<p><em>6. &nbsp;Search for user and require attributes.</em><br />
A filter is used to search for the user like was done in step 3 but we&#8217;ll add an extra check to the query to look for the attributes that show we&#8217;re authorized.</p>
<p>
<h3>Example Code</h3>
</p>
<p>The code shown here is using the JLDAP library from Novell. &nbsp;Interesting includes are noted at the top.  The utility class used for escaping the search filter can be found in the <a href="https://github.com/sakaiproject/nakamura/blob/master/contrib/ldap/src/main/java/org/sakaiproject/nakamura/api/ldap/LdapUtil.java">Sakai Project&#8217;s Nakamura codebase</a>.</p>
<p><pre class="brush: java;">
import com.novell.ldap.LDAPAttribute;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry;
import com.novell.ldap.LDAPException;
import com.novell.ldap.LDAPSearchResults;
// ...
String baseDn = &quot;ou=People,o=MyOrg&quot;;
String userFilter = &quot;uid = {}&quot;;
String authzFilter = &quot;authzAttr=special:Entitlement:value&quot;;
// ...
public boolean authenticate(Credentials credentials) throws RepositoryException {
    boolean auth = false;
    if (credentials instanceof SimpleCredentials) {
      // get application user credentials
      String appUser = connMgr.getConfig().getLdapUser();
      String appPass = connMgr.getConfig().getLdapPassword();

      // get user credentials
      SimpleCredentials sc = (SimpleCredentials) credentials;

      long timeStart = System.currentTimeMillis();

      String userDn = LdapUtil.escapeLDAPSearchFilter(userFilter.replace(&quot;{}&quot;,
          sc.getUserID()));
      String userPass = new String(sc.getPassword());

      LDAPConnection conn = null;
      try {
        // 1) Get a connection to the server
        try {
          conn = connMgr.getConnection();
          log.debug(&quot;Connected to LDAP server&quot;);
        } catch (LDAPException e) {
          throw new IllegalStateException(&quot;Unable to connect to LDAP server [&quot;
              + connMgr.getConfig().getLdapHost() + &quot;]&quot;);
        }

        // 2) Bind as app user
        try {
          conn.bind(LDAPConnection.LDAP_V3, appUser, appPass.getBytes(UTF8));
          log.debug(&quot;Bound as application user&quot;);
        } catch (LDAPException e) {
          throw new IllegalArgumentException(&quot;Can't bind application user [&quot; + appUser
              + &quot;]&quot;, e);
        }

        // 3) Search for username (not authz).
        // If search fails, log/report invalid username or password.
        LDAPSearchResults results = conn.search(baseDn, LDAPConnection.SCOPE_SUB, userDn,
            null, true);
        if (results.hasMore()) {
          log.debug(&quot;Found user via search&quot;);
        } else {
          throw new IllegalArgumentException(&quot;Can't find user [&quot; + userDn + &quot;]&quot;);
        }

        // 4) Bind as user.
        // If bind fails, log/report invalid username or password.

        // value is set below. define here for use in authz check.
        String userEntryDn = null;
        try {
          LDAPEntry userEntry = results.next();
          LDAPAttribute objectClass = userEntry.getAttribute(&quot;objectClass&quot;);

          if (&quot;aliasObject&quot;.equals(objectClass.getStringValue())) {
            LDAPAttribute aliasDN = userEntry.getAttribute(&quot;aliasedObjectName&quot;);
            userEntryDn = aliasDN.getStringValue();
          } else {
            userEntryDn = userEntry.getDN();
          }

          conn.bind(LDAPConnection.LDAP_V3, userEntryDn, userPass.getBytes(UTF8));
          log.debug(&quot;Bound as user&quot;);
        } catch (LDAPException e) {
          log.warn(&quot;Can't bind user [{}]&quot;, userDn);
          throw e;
        }

        if (authzFilter.length() &gt; 0) {
          // 5) Return to app user
          try {
            conn.bind(LDAPConnection.LDAP_V3, appUser, appPass.getBytes(UTF8));
            log.debug(&quot;Rebound as application user&quot;);
          } catch (LDAPException e) {
            throw new IllegalArgumentException(&quot;Can't bind application user [&quot; + appUser
                + &quot;]&quot;);
          }

          // 6) Search user DN with authz filter
          // If search fails, log/report that user is not authorized
          String userAuthzFilter = &quot;(&amp;(&quot; + userEntryDn + &quot;)(&quot; + authzFilter + &quot;))&quot;;
          results = conn.search(baseDn, LDAPConnection.SCOPE_SUB, userAuthzFilter, null,
              true);
          if (results.hasMore()) {
            log.debug(&quot;Found user + authz filter via search&quot;);
          } else {
            throw new IllegalArgumentException(&quot;User not authorized [&quot; + userDn + &quot;]&quot;);
          }
        }

        // FINALLY!
        auth = true;
        log.info(&quot;User [{}] authenticated with LDAP in {}ms&quot;, userDn,
            System.currentTimeMillis() - timeStart);
      } catch (Exception e) {
        log.warn(e.getMessage(), e);
      } finally {
        connMgr.returnConnection(conn);
      }
    }
    return auth;
  }
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=83&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2011/01/04/ldap-authentication-authorization-dissected-and-digested/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting Up RVM, Ruby, Gem and Rails on Ubuntu</title>
		<link>http://thecarlhall.wordpress.com/2010/10/18/setting-up-rvm-ruby-gem-and-rails-on-ubuntu/</link>
		<comments>http://thecarlhall.wordpress.com/2010/10/18/setting-up-rvm-ruby-gem-and-rails-on-ubuntu/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 03:41:54 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=169</guid>
		<description><![CDATA[This is centered on Ubuntu only because aptitude is used once. If you&#8217;re comfortable with your package manager feel free to replace the aptitude command with your local command. I&#8217;m beginning to dig deeper into ruby, rails and the whole &#8230; <a href="http://thecarlhall.wordpress.com/2010/10/18/setting-up-rvm-ruby-gem-and-rails-on-ubuntu/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=169&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>This is centered on Ubuntu only because aptitude is used once. If you&#8217;re comfortable with your package manager feel free to replace the aptitude command with your local command.</strong></p>
<p>I&#8217;m beginning to dig deeper into ruby, rails and the whole suite of tools available for them and have hit my knee on several things along the way. I&#8217;m no stranger to downloading things to download things to do things; I&#8217;ve been doing that in Java since 1996. I&#8217;ve also been kicking the tires on Ubuntu sense back before they got their naming scheme together and Debian even before that. I totally dig the Debian/Ubuntu way of install by deb packages. But with ruby, like Java, I feel it is best setup a machine by minimizing the use of apt (apt-get, aptitude, etc) and downloading the tools you need directly. I don&#8217;t let aptitude install Eclipse, Xalan, servlet-api or any of the other tools/libraries I use on top of the JVM and this is the route I have ended up going with when setting up ruby as well.</p>
<h2>TL;DR: short list of what to do</h2>
<p>This short list is for Ruby 1.9.2. If you want to install an earlier version, be sure to follow the extra steps about <a href="#install_gem">installing gem from rubygems.org</a>.</p>
<ol>
<li>Install RVM <a href="#install_rvm">[details]</a>:<br />
<pre class="brush: bash;">bash &lt; &gt; ~/.bashrc  # This loads RVM into a shell session.
source ~/.bashrc</pre></li>
<li>Install a C compiler for RVM <a href="#install_gcc">[details]</a>:<br />
<pre class="brush: bash;">sudo aptitude install gcc</pre></li>
<li>Install Ruby 1.9.2 using RVM <a href="#install_ruby">[details]</a>:
<p><em><a href="#install_gem">See below for instructions on installing RubyGems when using Ruby &lt; v1.9.2</a></em><br />
<pre class="brush: bash;">rvm pkg install zlib
rvm install 1.9.2 --default -C --with-zlib-dir=$HOME/.rvm/usr</pre></li>
<li>Install Rails using RubyGems <a href="#install_rails">[details]</a>:
<p><pre class="brush: bash;">gem install rails</pre></li>
</ol>
<h2>Details:</h2>
<p><a name="install_rvm"></a></p>
<h4>Install RVM</h4>
<p><em>Note: The <a href="http://rvm.beginrescueend.com/rvm/install/">full install instructions</a> have much better details.</em></p>
<p><a href="http://rvm.beginrescueend.com/">RVM (Ruby Version Manager)</a> gives us a way to install Ruby without getting it from aptitude. Being that Ruby is our starting point for everything after RVM and RVM is our means of getting Ruby, everything is downhill after getting RVM. You could install ruby using aptitude then install rvm as a gem but what&#8217;s the point of downloading Ruby just to download stuff to eventually download Ruby (again) and remove the system local stuff that was installed the first time. Let&#8217;s just cut out all the cruft in the middle.</p>
<p><a name="install_gcc"></a></p>
<h4>Install a C compiler for RVM</h4>
<p>Since RVM setups up the Ruby interpreter, it has to act 1 level deeper than the interpreter and C is that next level down. GCC is a very common tool to have on a linux machine, so this step is mostly for setting up a new machine. It&#8217;s always a good idea to have GCC installed. And vi. But this is a tech blog and not for theology, so I won&#8217;t go into that.</p>
<p>&nbsp;</p>
<h4>Install Ruby 1.9.2 using RVM</h4>
<p>The big moment! All this work to get Ruby installed so we can begin our journey into RoR-land. This will take some time to perform as it needs to download, configure and compile Ruby.</p>
<p>&nbsp;</p>
<h5><em>Install RubyGems from rubygems.org for Ruby &lt; v1.9.2</em></h5>
<p><em>Note: The <a href="http://docs.rubygems.org/read/chapter/3">full install instructions</a> have much better details.</em></p>
<p><pre class="brush: bash;">
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar zxf rubygems-1.3.7.tgz
cd rubygems-1.3.7
ruby setup.rb</pre></p>
<p>Ruby 1.9.2 includes RubyGems 1.3.7, so we don&#8217;t have to install it when we install Ruby, but for previous versions we&#8217;ll need to install this bit ourselves. You can install it from aptitude but it locks you from doing system updates and some other functionality I wasn&#8217;t keen on losting. Installing it from rubygems.org gives back the freedom to break my system in whatever way I choose.</p>
<p><a name="install_rails"></a></p>
<h4>Install Rails using RubyGems</h4>
<p>This is where things get down to Ruby&#8217;s style of easy. Package management that looks like an already very easy package manager (aptitude) is a bonus in my book. Installing gems will become something you most likely get very comfortable with as this is the easiest way to get the libraries you need for your Ruby installation. Read more into <a href="http://rvm.beginrescueend.com/gemsets/">RVM Gemsets</a> to see where this stuff gets even cooler.<br />
<em>Note: If you get this error message:<br />
</em></p>
<p><pre class="brush: bash;">ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib</pre></p>
<p><em><br />
take a look <a href="http://rvm.beginrescueend.com/packages/zlib/">at this page for installing Ruby with zlib</a>. I tripped over this nicely.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=169&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2010/10/18/setting-up-rvm-ruby-gem-and-rails-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting &#8220;quoted-printable&#8221; In A commons-email Body Part</title>
		<link>http://thecarlhall.wordpress.com/2010/09/01/setting-quoted-printable-in-a-commons-email-body-part/</link>
		<comments>http://thecarlhall.wordpress.com/2010/09/01/setting-quoted-printable-in-a-commons-email-body-part/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 03:40:20 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=154</guid>
		<description><![CDATA[I&#8217;m revamping the inner workings of a mail sending tool to use commons-email.  I wanted to make sure I set the text body parts to the appropriate transfer encoding to allow for non-ASCII languages to be used. My failed attempts &#8230; <a href="http://thecarlhall.wordpress.com/2010/09/01/setting-quoted-printable-in-a-commons-email-body-part/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=154&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m revamping the inner workings of a mail sending tool to use <a href="http://commons.apache.org/email">commons-email</a>.  I wanted to make sure I set the text body parts to the appropriate transfer encoding to allow for non-ASCII languages to be used.  My failed attempts and final success are documented below.</p>
<h3><span style="color:red;">1. [bad] Set Message &#8216;Content-transfer-encoding&#8217;</span></h3>
<p>The problem with this is that everything in the message is processed as &#8220;quoted-printable&#8221; which will turn your multipart boundaries into useless wastes of text.</p>
<p><pre class="brush: java;">
// this chews up your multipart boundary
HtmlEmail email = new HtmlEmail();
email.addHeader(&quot;Content-transfer-encoding&quot;, &quot;quoted-printable&quot;);
</pre></p>
<p>So rather than having this in your raw email <em>(note reported and actual boundary match)</em>:</p>
<p><code>Content-Type: multipart/alternative;<br />
boundary="----=_Part_7_1164835397.1283397465477"</code></p>
<p><code> </code></p>
<p><code>------=_Part_7_1164835397.1283397465477<br />
Content-Type: text/plain; charset=UTF-8<br />
</code></p>
<p>You end up with this in your raw email <em>(note: actual boundary has = replaced by =3D)</em>:</p>
<p><code>Content-Type: multipart/alternative;<br />
boundary="----=_Part_7_1164835397.1283397465477"</code></p>
<p><code> </code></p>
<p><code>----=3D_Part_7_1164835397.1283397465477<br />
Content-Type: text/plain; charset=UTF-8<br />
</code></p>
<h3><span style="color:red;">2. [useless] Setting Each Body Part&#8217;s transfer encoding</span></h3>
<p>I&#8217;ll save you the pain.  This begins to turn commons-email back into javamail.  It saves you nothing, adds lots of code, doesn&#8217;t really work and, given the next solution, is the wrong approach.</p>
<h3><span style="color:green;">3. [Best!] Let commons-email do it&#8217;s job</span></h3>
<p>The solution I ended up with is to just let commons-email figure it out.  My test text is &#8220;You get that thing I sent you?\n3x6=18\nåæÆÐ&#8221;.  This has several non-ASCII characters that are just ripe for conversion.  The raw bit of email I find is:<br />
<code>------=_Part_4_644193719.1283397465436<br />
Content-Type: text/plain; charset=UTF-8<br />
Content-Transfer-Encoding: quoted-printable</code></p>
<p><code> </code></p>
<p><code>You get that thing I sent you?<br />
3x6=3D18<br />
=C3=A5=C3=A6=C3=86=C3=90</code></p>
<p>The content-transfer-encoding is set as I expected and the content has been properly escaped.  Kudus to the commons-email team for making this just happen.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=154&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2010/09/01/setting-quoted-printable-in-a-commons-email-body-part/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Thrift into Maven Locally</title>
		<link>http://thecarlhall.wordpress.com/2010/08/27/getting-thrift-into-maven-locally/</link>
		<comments>http://thecarlhall.wordpress.com/2010/08/27/getting-thrift-into-maven-locally/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 22:20:06 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java ant maven]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=142</guid>
		<description><![CDATA[I spent the better part of a morning trying to figure out how to get Thrift to be available in a Maven repository for a project I&#8217;m working on. Yes, I know there&#8217;s a JIRA issue for this but the &#8230; <a href="http://thecarlhall.wordpress.com/2010/08/27/getting-thrift-into-maven-locally/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=142&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I spent the better part of a morning trying to figure out how to get Thrift to be available in a Maven repository for a project I&#8217;m working on.  Yes, I know there&#8217;s <a href="https://issues.apache.org/jira/browse/THRIFT-363">a JIRA issue for this</a> but the comments are not clear and it&#8217;s more tailored towards publishing in the central Apache repository.  Also, I tried using &#8216;ant publish&#8217; and got &#8220;Execute failed: java.io.IOException: Cannot run program &#8220;../../compiler/cpp/thrift&#8221;: java.io.IOException: error=2, No such file or directory&#8221;.  I don&#8217;t need that kind of problem installing a library nor do I want to build the whole Thrift library.</p>
<p>What I did to finally get this into my local maven repository is this.</p>
<ol>
<li>Download and unarchive the latest stable Thrift release
<ul>
<li><a href="http://incubator.apache.org/thrift/download/">http://incubator.apache.org/thrift/download/</a></li>
</ul>
</li>
<li>Change into the Thrift Java root directory
<ul>
<li>cd lib/java</li>
</ul>
</li>
<li>Run the default ant target, &#8220;dist&#8221;
<ul>
<li>ant</li>
</ul>
</li>
<li>Install the build artifact into the local Maven repository.  <em>Note: Be sure to update the version to match what you downloaded.</em></li>
<ul>
<li>mvn install:install-file -Dfile=libthrift.jar -DgroupId=org.apache.thrift -DartifactId=libthrift -Dversion=0.4.0 -Dpackaging=jar -DgeneratePom=true</li>
</ul>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=142&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2010/08/27/getting-thrift-into-maven-locally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
		<item>
		<title>Find and Remove Files That Have Spaces In The Name</title>
		<link>http://thecarlhall.wordpress.com/2010/07/09/find-and-remove-files-that-have-spaces-in-the-name/</link>
		<comments>http://thecarlhall.wordpress.com/2010/07/09/find-and-remove-files-that-have-spaces-in-the-name/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 16:35:03 +0000</pubDate>
		<dc:creator>thecarlhall</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://thecarlhall.wordpress.com/?p=112</guid>
		<description><![CDATA[Whenever I need this, it takes me seemingly forever to figure this out. Blog it! &#8216;find&#8217; is a great GNU utility for digging up files in directories. &#8216;rm&#8217; is a staple command for any linux user. Combining the two commands &#8230; <a href="http://thecarlhall.wordpress.com/2010/07/09/find-and-remove-files-that-have-spaces-in-the-name/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=112&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Whenever I need this, it takes me seemingly forever to figure this out.  Blog it!</p>
<p>&#8216;find&#8217; is a great GNU utility for digging up files in directories.  &#8216;rm&#8217; is a staple command for any linux user.  Combining the two commands can be fun and powerful.</p>
<p><pre class="brush: bash;">
find /home/luser -type f -name '*.mpg' -exec rm -f {} \;
</pre></p>
<p>The above command calls &#8216;rm -f&#8217; for each file.  A faster version of this uses xargs for a single call.</p>
<p><pre class="brush: bash;">
find /home/luser -type f -name '*.mpg' | xargs rm -f
</pre></p>
<p>Hooray!  We just deleted all mpg files in luer&#8217;s home directory.  Unless, of course, any of those files had a name that included a space.  Doh!  One way to get around this is to use this modified version of the above command.</p>
<p><pre class="brush: bash;">
find /home/luser -type f -name '*.mpg' | tr &quot;\n&quot; &quot;&#092;&#048;00&quot; | xargs -0 rm -f
</pre></p>
<p><strong>Update:</strong> As Stuart notes in the comments, you should be able to replace the &#8216;tr&#8217; command with the find -print0 option.  I wasn&#8217;t able to get it to work, but maybe it helps you!<br />
<pre class="brush: bash;">
find /home/luser -type f -name '*.mpg' -print0 | xargs -0 rm -f
</pre></p>
<p><strong>Update #2:</strong> As Ole notes in the comments, GNU parallel is another option which provides parallel process running.<br />
<pre class="brush: bash;">
find /home/luser -type f -name ‘*.mpg’ | parallel rm -f
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecarlhall.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecarlhall.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecarlhall.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecarlhall.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecarlhall.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecarlhall.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecarlhall.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecarlhall.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecarlhall.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecarlhall.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecarlhall.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecarlhall.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecarlhall.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecarlhall.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecarlhall.wordpress.com&amp;blog=6233168&amp;post=112&amp;subd=thecarlhall&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecarlhall.wordpress.com/2010/07/09/find-and-remove-files-that-have-spaces-in-the-name/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18aed3fab9203b50799919212be5f600?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thecarlhall</media:title>
		</media:content>
	</item>
	</channel>
</rss>
