felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Felix > Quick Start (Source)
Date Tue, 22 Sep 2009 16:05:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/FELIX/Quick+Start+%28Source%29">Quick
Start (Source)</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~gnodet">Guillaume
Nodet</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable  {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color:
#f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}

/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td
width='33%' class='ScrollbarPrevName'>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/FELIX/1.+Quick+Start"><img border='0' align='middle' src='/confluence/images/icons/up_16.gif'
width='8' height='8'></a></sup><a href="/confluence/display/FELIX/1.+Quick+Start">1.
Quick Start</a></td><td width='33%' class='ScrollbarNextName'>&nbsp;</td></tr></table></div>
<p><a name="QuickStart%28Source%29-top"></a></p>

<h1><a name="QuickStart%28Source%29-1.QuickStart%28Source%29"></a>1. Quick
Start (Source)</h1>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><p>Karaf is
still working towards it's first release at Felix.</p>

<p>Alternatively see <a href="/confluence/display/FELIX/1.+Quick+Start" title="1.
Quick Start">1. Quick Start</a>.</p></td></tr></table></div>

<p>If you are in a hurry to have Apache Felix Karaf up and running right away, this
section will provide you with some basic steps for checking out, building and running the
server in no time. This is clearly not a complete guide so you may want to check other sections
of this guide for further information.</p>

<p>All you need is 15 minutes and to follow these basic steps.</p>
<ul>
	<li><a href="#QuickStart%28Source%29-Background">Background</a></li>
	<li><a href="#QuickStart%28Source%29-Gettingthesoftware">Getting the software</a></li>
	<li><a href="#QuickStart%28Source%29-Starttheserver">Start the server</a></li>
	<li><a href="#QuickStart%28Source%29-Deployasampleapplication">Deploy a sample
application</a></li>
</ul>


<h2><a name="QuickStart%28Source%29-Background"></a>Background</h2>

<p>Apache Felix Karaf is a small and lightweight OSGi based runtime.  This provides
a small lightweight container onto which various bundles can be deployed.</p>
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><p>Apache Felix Karaf started
life as the <a href="http://servicemix.apache.org" rel="nofollow">Apache ServiceMix
</a> kernel.<br/>
Don't be surprised by any transitional references which remain. </p></td></tr></table></div>
<p><a href="#QuickStart%28Source%29-top">top</a></p>

<h2><a name="QuickStart%28Source%29-Gettingthesoftware"></a>Getting the
software</h2>

<p>This document describes how to build the server from the latest Karaf source. </p>

<h3><a name="QuickStart%28Source%29-Prerequisites"></a>Prerequisites</h3>

<p>Although this installation path is the fastest one, still you will need to install
some software before installing Karaf.</p>

<p>Karaf requires a Java 5 environment to run. Refer to <a href="http://java.sun.com"
rel="nofollow">http://java.sun.com</a> for details on how to download and install
J2SE 1.5 or greater.</p>

<p><a href="http://subversion.tigris.org" rel="nofollow">Subversion </a>
is required to checkout the source.</p>

<p><a href="http://maven.apache.org" rel="nofollow">Maven 2</a> is required
to build Karaf.</p>

<h3><a name="QuickStart%28Source%29-CheckoutSource"></a>Checkout Source</h3>

<p>The Karaf source is found at <a href="http://svn.apache.org/repos/asf/felix/trunk/karaf/"
rel="nofollow">http://svn.apache.org/repos/asf/felix/trunk/karaf/</a>. To check out
with a command line client:</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">
$ svn co http:<span class="code-comment">//svn.apache.org/repos/asf/felix/trunk/karaf/</span>
</pre>
</div></div> 

<h3><a name="QuickStart%28Source%29-Build"></a>Build</h3>

<p>Change directory to the top level of the source checkout. Build Karaf using Maven
as follows:</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">
$ mvn -Pfastinstall
</pre>
</div></div>

<p>Distributions will be created in assembly/target. Select the file compression format
compatible with your system (apache-felix-karaf-1.0.0.zip for windows, apache-felix-karaf-1.0.0.tar.gz
for unixes) and expand the binary in a new directory; for example in z:\karaf - from now on
this directory will be referenced as &lt;KARAF_HOME&gt;. Please remember the restrictions
concerning illegal characters in Java paths, e.g. &#33;, % etc.</p>

<p>The installation of Karaf is as simple as uncompressing the .zip or .tar files. The
next step is to start the server.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><p>To generate Eclipse projects
for all modules, in KARAF_HOME type:</p>

<p>mvn -Psetup.eclipse </p>

<p>Then add each module location, prefixing each name with <em>org.apache.felix.karaf</em>
(for example <em>org.apache.felix.karaf.shell.core</em>)</p></td></tr></table></div>

<p><a href="#QuickStart%28Source%29-top">top</a></p>

<h2><a name="QuickStart%28Source%29-Starttheserver"></a>Start the server</h2>

<p>With Karaf already installed, open a command line console and change directory to
&lt;KARAF_HOME&gt;. To start the server, run the following command in Windows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
bin\karaf.bat
</pre>
</div></div>
<p>respectively on Unix:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
bin/karaf
</pre>
</div></div>
<p>You should see the following informations on the command line console:</p>
<div class="panel" style="background-color: #000000;border-width: 1px;"><div class="panelContent"
style="background-color: #000000;">
<p><font color="#00ffff"><pre>        __ __                  ____      
       / //_/____ __________ _/ __/      
      / ,&lt;  / __ `/ ___/ __ `/ /_        
     / /| |/ /_/ / /  / /_/ / __/        
    /_/ |_|\__,_/_/   \__,_/_/         

</pre></font><font color="#c0c0c0"><pre>  Apache Felix Karaf (1.0.0)

Hit '&lt;tab&gt;' for a list of available commands
and '[cmd] --help' for help on a specific command.

karaf@root&gt; 
</pre></font></p>
</div></div>
<p>You can now run your first command.  Simply type the <tt>&lt;tab&gt;</tt>
key in the console.</p>
<div class="panel" style="background-color: #000000;border-width: 1px;"><div class="panelContent"
style="background-color: #000000;">
<p><font color="#c0c0c0">
<pre>karaf@root&gt; 

admin:change-port        admin:connect            admin:create             admin:destroy 
          admin:list               admin:start
admin:stop               config:cancel            config:edit              config:list   
          config:propappend        config:propdel
config:proplist          config:propset           config:update            features:addUrl
         features:install         features:list
features:listUrl         features:refreshUrl      features:removeUrl       features:uninstall
      log:display              log:display-exception
log:get                  log:set                  osgi:bundle-level        osgi:headers  
          osgi:install             osgi:list
osgi:ls                  osgi:refresh             osgi:resolve             osgi:restart  
          osgi:shutdown            osgi:start
osgi:start-level         osgi:stop                osgi:uninstall           osgi:update   
          packages:exports         packages:imports
shell:cat                shell:echo               shell:exec               shell:grep    
          shell:info               shell:java
shell:printf             shell:sleep              shell:sort               shell:tac     
          ssh:ssh                  ssh:sshd
karaf@root&gt; 
</pre></font></p>
</div></div>
<p><a href="#QuickStart%28Source%29-top">top</a></p>

<h2><a name="QuickStart%28Source%29-Deployasampleapplication"></a>Deploy
a sample application</h2>

<p>While you will learn in the remainder of this guide how to use and leverage Apache
Felix Karaf, we will just use the pre-built packaging for now.</p>

<p>In the console, run the following commands:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
features:install spring-dm
osgi:install -s mvn:org.apache.geronimo.specs/geronimo-activation_1.1_spec/1.0.2
osgi:install -s mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.1.0
osgi:install -s mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxb-api-2.1/1.1.0
osgi:install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/2.1.6_1
osgi:install -s mvn:org.apache.camel/camel-core/1.4.0
osgi:install -s mvn:org.springframework/spring-tx/2.5.6.SEC01
osgi:install -s mvn:org.apache.camel/camel-spring/1.4.0
osgi:install -s mvn:org.apache.camel/camel-osgi/1.4.0
osgi:install -s mvn:org.apache.camel/camel-example-osgi/1.4.0
</pre>
</div></div>
<p>This commands will download, install and start the specified jars.</p>

<p>The example installed is using <a href="http://activemq.apache.org/camel" rel="nofollow">Camel</a>
to start a timer every 2 seconds and output a message on the console.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&gt;&gt;&gt;&gt; MyTransform set body:  Wed Jan 02 23:34:19 CET 2008
&gt;&gt;&gt;&gt; MyTransform set body:  Wed Jan 02 23:34:21 CET 2008
</pre>
</div></div>

<h3><a name="QuickStart%28Source%29-Stoppinganduninstallingthesampleapplication"></a>Stopping
and uninstalling the sample application</h3>

<p>To stop this demo, run the following command:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
osgi:list | grep example
</pre>
</div></div>
<p>In the output, locate the line containing <tt>camel-example-osgi</tt>
and note the id of the bundle in the first column.  Then launch the following command:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
osgi:stop [id]
</pre>
</div></div>
<p>If you wish, you can start again the sample by using the following command:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
osgi:start [id]
</pre>
</div></div>
<p>To uninstall the demo, run the following command:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
osgi:uninstall [id]
</pre>
</div></div>

<h3><a name="QuickStart%28Source%29-CommonProblems"></a>Common Problems</h3>

<ol>
	<li>Launching SMX4 can result in a deadlock in Felix during module dependency resolution.
 This is often a result of sending a SIGINT (control-C) to the process when it will not cleanly
exit.  This can corrupt the caches and cause startup problems in the very next launch. It
is fixed by emptying the component cache:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
rm -rf data/cache/*
</pre>
</div></div></li>
</ol>


<h2><a name="QuickStart%28Source%29-StoppingKaraf"></a>Stopping Karaf</h2>

<p>To stop Karaf from the console, enter <tt>^D</tt> in the console:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
^D
</pre>
</div></div>
<p>Alternatively, you can also run the following command:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
osgi:shutdown
</pre>
</div></div>

<h2><a name="QuickStart%28Source%29-Summary"></a>Summary</h2>

<p>This document showed you how simple it is to have Apache Felix Karaf up and running.
The overall time for getting the server running should be less than five minutes if you have
the prerequisite (Java 1.5) already installed. Additionally, this article also showed you
how to deploy and test a simple Apache Camel application in less than five minutes.</p>

<p><a href="#QuickStart%28Source%29-top">top</a></p>
<style type='text/css'>/*<![CDATA[*/
table.ScrollbarTable  {border: none;padding: 3px;width: 100%;padding: 3px;margin: 0px;background-color:
#f0f0f0}
table.ScrollbarTable td.ScrollbarPrevIcon {text-align: center;width: 16px;border: none;}
table.ScrollbarTable td.ScrollbarPrevName {text-align: left;border: none;}
table.ScrollbarTable td.ScrollbarParent {text-align: center;border: none;}
table.ScrollbarTable td.ScrollbarNextName {text-align: right;border: none;}
table.ScrollbarTable td.ScrollbarNextIcon {text-align: center;width: 16px;border: none;}

/*]]>*/</style><div class="Scrollbar"><table class='ScrollbarTable'><tr><td
width='33%' class='ScrollbarPrevName'>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/FELIX/1.+Quick+Start"><img border='0' align='middle' src='/confluence/images/icons/up_16.gif'
width='8' height='8'></a></sup><a href="/confluence/display/FELIX/1.+Quick+Start">1.
Quick Start</a></td><td width='33%' class='ScrollbarNextName'>&nbsp;</td></tr></table></div>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/FELIX/Quick+Start+%28Source%29">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=117788&revisedVersion=6&originalVersion=5">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/FELIX/Quick+Start+%28Source%29?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message