karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Karaf > 2. Quick Start
Date Tue, 13 Jul 2010 09:33:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/3/_/styles/combined.css?spaceKey=KARAF&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/KARAF/2.+Quick+Start">2.
Quick Start</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~gnodet">Guillaume
Nodet</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Deploy a sample application <br>
<br></td></tr>
            <tr><td class="diff-changed-lines" >While you will learn in the remainder
of this guide how to use and leverage Apache <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Felix</span>
Karaf, we will just use the pre-built packaging for now. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>In the console, run the
following commands: <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >The example installed is using [Camel|http://camel.apache.org]
to start a timer every 2 seconds and output a message on the console. <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" >&gt;&gt;&gt;&gt;
MyTransform set body:  Wed Jan 02 23:34:19 CET <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">2008</span>
<span class="diff-added-words"style="background-color: #dfd;">2010</span> <br></td></tr>
            <tr><td class="diff-changed-lines" >&gt;&gt;&gt;&gt;
MyTransform set body:  Wed Jan 02 23:34:21 CET <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">2008</span>
<span class="diff-added-words"style="background-color: #dfd;">2010</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Summary <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >This document showed you how simple
it is to have Apache 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 <span class="diff-changed-words"><span
class="diff-added-chars"style="background-color: #dfd;">[</span>Apache Camel<span
class="diff-added-chars"style="background-color: #dfd;">|http://camel.apache.org]</span></span>
application in less than five minutes. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>[#top] <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <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
class='ScrollbarPrevIcon'><a href="/confluence/display/KARAF/1.+Overview"><img
border='0' align='middle' src='/confluence/images/icons/back_16.gif' width='16' height='16'></a></td><td
width='33%' class='ScrollbarPrevName'><a href="/confluence/display/KARAF/1.+Overview">1.
Overview</a>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/KARAF/Karaf+Users%27+Guide"><img border='0' align='middle'
src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a
href="/confluence/display/KARAF/Karaf+Users%27+Guide">Karaf Users' Guide</a></td><td
width='33%' class='ScrollbarNextName'>&nbsp;<a href="/confluence/display/KARAF/3.+Installation">3.
Installation</a></td><td class='ScrollbarNextIcon'><a href="/confluence/display/KARAF/3.+Installation"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></!
 div>
<p><a name="2.QuickStart-top"></a></p>

<h1><a name="2.QuickStart-2.Quickstart"></a>2. Quick start</h1>

<p>If you are in a hurry to have Apache Karaf up and running right away, this section
will provide you with some basic steps for downloading, building (when needed) 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 5 to 10 minutes and to follow these basic steps.</p>
<ul>
	<li><a href="#2.QuickStart-Background">Background</a></li>
	<li><a href="#2.QuickStart-Gettingthesoftware">Getting the software</a></li>
	<li><a href="#2.QuickStart-Starttheserver">Start the server</a></li>
	<li><a href="#2.QuickStart-Deployasampleapplication">Deploy a sample application</a></li>
</ul>


<h2><a name="2.QuickStart-Background"></a>Background</h2>

<p>Apache 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>Apache Karaf started life as the
<a href="http://servicemix.apache.org" class="external-link" rel="nofollow">Apache ServiceMix</a>
kernel and then moved as a <a href="http://felix.apache.org" class="external-link" rel="nofollow">Apache
Felix</a> subproject.<br/>
Don't be surprised by any transitional references which remain.</td></tr></table></div>
<p><a href="#2.QuickStart-top">top</a></p>

<h2><a name="2.QuickStart-Gettingthesoftware"></a>Getting the software</h2>

<p>At this time you have one option to get the software. The fastest and easiest way
is to get the binary directly from the Apache site. Since this article is intended to help
you to have Apache Karaf up and running in the fastest way only the binary download will be
covered at this time.</p>

<h3><a name="2.QuickStart-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"
class="external-link" rel="nofollow">http://java.sun.com</a> for details on how to
download and install J2SE 1.5 or greater.</p>

<h3><a name="2.QuickStart-Downloadbinaries"></a>Download binaries</h3>

<p>Depending on the platform you plan to install and run Karaf you will select the appropriate
installation image. Open a Web browser and access the following URL, there you will find the
available packages for download (binaries and source code).</p>

<p><a href="http://karaf.apache.org/download.html" class="external-link" rel="nofollow">http://karaf.apache.org/download.html</a></p>

<p>Select the file compression format compatible with your system (zip for windows,
tar.gz for unixes) by clicking directly on the link, download it and expand the binary to
your hard drive 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>

<p><a href="#2.QuickStart-top">top</a></p>

<h2><a name="2.QuickStart-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="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">
        __ __                  ____      
       / <span class="code-comment">//_/____ __________ _/ __/      
</span>      / ,&lt;  / __ `/ ___/ __ `/ /_        
     / /| |/ /_/ / /  / /_/ / __/        
    /_/ |_|\__,_/_/   \__,_/_/         

  Apache Felix Karaf (2.0.0)

Hit '&lt;tab&gt;' <span class="code-keyword">for</span> a list of available
commands
and '[cmd] --help' <span class="code-keyword">for</span> help on a specific command.

karaf@root&gt; 
</pre>
</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="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">
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             dev:dynamic-<span
class="code-keyword">import</span>
dev:framework             dev:print-stack-traces    dev:show-tree             features:addUrl
features:info             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:clear               shell:each                shell:echo                shell:exec
shell:grep                shell:history             shell:<span class="code-keyword">if</span>
                 shell:info
shell:java                shell:logout              shell:<span class="code-keyword">new</span>
                shell:printf
shell:sleep               shell:sort                shell:tac                 ssh:ssh
ssh:sshd                  cat                       clear                     each
echo                      exec                      grep                      history
<span class="code-keyword">if</span>                        info             
        java                      logout
<span class="code-keyword">new</span>                       printf           
        sleep                     sort
tac                       bundle-level              headers                   install
list                      ls                        refresh                   resolve
restart                   shutdown                  start                     start-level
stop                      uninstall                 update
karaf@root&gt; 
</pre>
</div></div>

<p>You can then grab more specific help for a given command using the <tt>--help</tt>
option for this command:</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">
karaf@root&gt; admin:create --help
DESCRIPTION
	admin:create

	Create a <span class="code-keyword">new</span> instance.

SYNTAX
	admin:create [options] name

ARGUMENTS
        name
                The name of the <span class="code-keyword">new</span> container
instance

OPTIONS
        --help
                Display <span class="code-keyword">this</span> help message
        -f, --feature
                Initial features. This option can be specified multiple times to enable multiple
initial 
                features
        -p, --port
                Port number <span class="code-keyword">for</span> remote shell
connection
        -l, --location
                Location of the <span class="code-keyword">new</span> container
instance in the file system
        -furl, --featureURL
                Additional feature descriptor URLs. This option can be specified multiple
times to add 
                multiple URLs

karaf@root&gt; 
</pre>
</div></div>

<p>Note that the console supports tab completion, so you just need to enter <tt>ad
&lt;tab&gt; cr &lt;tab&gt;</tt> instead of <tt>admin:create</tt>.<br/>
<a href="#2.QuickStart-top">top</a></p>

<h2><a name="2.QuickStart-Deployasampleapplication"></a>Deploy a sample
application</h2>

<p>While you will learn in the remainder of this guide how to use and leverage Apache
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://camel.apache.org" class="external-link"
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 2010
&gt;&gt;&gt;&gt; MyTransform set body:  Wed Jan 02 23:34:21 CET 2010
</pre>
</div></div>

<h3><a name="2.QuickStart-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="2.QuickStart-CommonProblems"></a>Common Problems</h3>

<ol>
	<li>Launching Karaf 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="2.QuickStart-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="2.QuickStart-Summary"></a>Summary</h2>

<p>This document showed you how simple it is to have Apache 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 <a href="http://camel.apache.org" class="external-link" rel="nofollow">Apache
Camel</a> application in less than five minutes.</p>

<p><a href="#2.QuickStart-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
class='ScrollbarPrevIcon'><a href="/confluence/display/KARAF/1.+Overview"><img
border='0' align='middle' src='/confluence/images/icons/back_16.gif' width='16' height='16'></a></td><td
width='33%' class='ScrollbarPrevName'><a href="/confluence/display/KARAF/1.+Overview">1.
Overview</a>&nbsp;</td><td width='33%' class='ScrollbarParent'><sup><a
href="/confluence/display/KARAF/Karaf+Users%27+Guide"><img border='0' align='middle'
src='/confluence/images/icons/up_16.gif' width='8' height='8'></a></sup><a
href="/confluence/display/KARAF/Karaf+Users%27+Guide">Karaf Users' Guide</a></td><td
width='33%' class='ScrollbarNextName'>&nbsp;<a href="/confluence/display/KARAF/3.+Installation">3.
Installation</a></td><td class='ScrollbarNextIcon'><a href="/confluence/display/KARAF/3.+Installation"><img
border='0' align='middle' src='/confluence/images/icons/forwd_16.gif' width='16' height='16'></a></td></tr></table></!
 div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/KARAF/2.+Quick+Start">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=74692&revisedVersion=45&originalVersion=44">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/KARAF/2.+Quick+Start?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message