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 Mon, 12 Jul 2010 09:05: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 (9)</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" >h1. 2. Quick start <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >If you are in a hurry to have
Apache <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Felix</span>
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. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>All you need is 5 to 10
minutes and to follow these basic steps. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Background <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Apache <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Felix</span>
Karaf is a small and lightweight OSGi based runtime.  This provides a small lightweight container
onto which various bundles can be deployed. <br></td></tr>
            <tr><td class="diff-unchanged" >{tip} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Apache
Felix Karaf started life as the [Apache ServiceMix | http://servicemix.apache.org] kernel.
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Apache
Karaf started life as the [Apache ServiceMix|http://servicemix.apache.org] kernel and then
moved as a [Apache Felix|http://felix.apache.org] subproject. <br></td></tr>
            <tr><td class="diff-unchanged" >Don&#39;t be surprised by any
transitional references which remain.  <br>{tip} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >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). <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">[http://felix.apache.org/site/downloads.cgi]</span>
<span class="diff-added-words"style="background-color: #dfd;">[http://karaf.apache.org/download.html]</span>
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >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 <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">z:\servicemix</span>
<span class="diff-added-words"style="background-color: #dfd;">z:\karaf</span>
- 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. \!, % etc. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>The installation of Karaf
is as simple as uncompressing the .zip or .tar files. The next step is to start the server.
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Start the server <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >With Karaf already installed,
open a command line console and change directory to <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">&lt;SERVICEMIX_HOME&gt;.</span>
<span class="diff-added-words"style="background-color: #dfd;">&lt;KARAF_HOME&gt;.</span>
To start the server, run the following command in Windows: <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>bin\karaf.bat <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >This commands will download, install
and start the specified jars. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >The example installed is using
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">[Camel|http://activemq.apache.org/camel]</span>
<span class="diff-added-words"style="background-color: #dfd;">[Camel|http://camel.apache.org]</span>
to start a timer every 2 seconds and output a message on the console. <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>&gt;&gt;&gt;&gt;
MyTransform set body:  Wed Jan 02 23:34:19 CET 2008 <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 <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Felix</span>
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. <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 Felix 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 (1.6.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            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>
</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] [VAL]

ARGUMENTS
	VAL	Name of the <span class="code-keyword">new</span> Karaf instance

OPTIONS
	-p, --port
		Port number <span class="code-keyword">for</span> remote shell connection
	--help
		Display <span class="code-keyword">this</span> help message
	-l, --location
		Location of the <span class="code-keyword">new</span> instance on the file system

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
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://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 2008
&gt;&gt;&gt;&gt; MyTransform set body:  Wed Jan 02 23:34:21 CET 2008
</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 Apache Camel 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=43&originalVersion=42">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