Hi Jean-Baptiste,

Thank you.
The default-activation attribute was not explicitly set, so implicitly it should have been eager.
I tried it with both values: same result.
JDK 1.5 or 1.6 makes no difference.

I made org.apache.karaf/karaf/2.2.1 the parent POM of the hello world command POM (didn't help).
This is the reason for the Apache stuff appearing in the manifest:
Manifest-Version: 1.0
Export-Package: com.isd.jm.karaf.cmd;uses:="org.apache.karaf.shell.con
 sole,org.apache.felix.gogo.commands"
Built-By: Stefan
Tool: Bnd-1.15.0
Bundle-Name: Unnamed - org.apache.karaf:osgi.test:bundle:2.2.1
Created-By: Apache Maven Bundle Plugin
Bundle-Vendor: The Apache Software Foundation
Build-Jdk: 1.6.0_22
Bundle-Version: 2.2.1
Bnd-LastModified: 1305363687364
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: The Apache Software Foundation provides support fo
 r the Apache community of open-source software projects.    The Apach
 e projects are characterized by a collaborative, consensus based deve
 lopment process, an open and    pragmatic software license, and a des
 ire to create high quality software that leads the way in its field.
    We consider ourselves not simply a group of projects sharing a ser
 ver, but rather a community of developers    and users.
Bundle-SymbolicName: osgi.test
Bundle-DocURL: http://www.apache.org/
Import-Package: org.apache.felix.gogo.commands;version="[0.6,1)",org.a
 pache.karaf.shell.console;version="[2.2,3)",org.osgi.service.blueprin
 t;version="[1.0.0,2.0.0)"

Blueprint:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"; default-activation="eager">
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0";>
<command name="hello/world">
<action class="com.isd.jm.karaf.cmd.HelloWorldCmd"/>
</command>
</command-bundle>
</blueprint>

Java:
package com.isd.jm.karaf.cmd;

import org.apache.felix.gogo.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;

@Command(scope = "hello", name = "world")
public class HelloWorldCmd extends OsgiCommandSupport
{
    @Override
    protected Object doExecute() throws Exception
    {
        System.out.println("Hello World!");
        return null;
    }
}

POM:
<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.karaf</groupId>
<artifactId>karaf</artifactId>
<version>2.2.1</version>
</parent>
<artifactId>osgi.test</artifactId>
<packaging>bundle</packaging>

<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>
                            com.isd.jm.karaf.cmd
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
</dependencies>
</project>

It is somehow weired, it is such a basic thing and the core Karaf commands work fine with Equinox...

Regards, Stefan

Am 14.05.2011 07:41, schrieb Jean-Baptiste Onofré:
Hi Stefan,

in the OSGI-INF/blueprint/*.xml of your command, what's your default-activation (eager or lazy) ?

Could you try to use eager in place of lazy ?
Could you paste your MANIFEST also to see the OSGi package statements ?

Thanks
Regards
JB

On 05/14/2011 01:56 AM, Stefan Eder wrote:
Hi,

I have a problem extending the console with own commands, when I run
Karaf with Equinox.

To check this problem again, I installed a simple "Hello World" command
with blueprint and minimal dependencies on Karaf/Felix and on
Karaf/Equinox, both in a virgin state (deleted data directory).

With Karaf/Felix the command is executed, with Karaf/Equinox it is not
executed. Instead I get the error message "Command not found: hello:world".

I am running the latest release 2.2.1, build on my system, but I have
also reproduced the problem with the 2.2.0 binary distribution.

The following log outputs appears only with Karaf/Felix:
org.apache.aries.blueprint - 0.3.0 | Retrieving service for bundle
org.apache.karaf.shell.console [22] and service registration
org.apache.felix.framework.ServiceRegistrationImpl@5cd5a2a9
org.apache.aries.blueprint - 0.3.0 | Creating service instance
org.apache.aries.blueprint - 0.3.0 | Service created:
org.apache.karaf.shell.console.commands.BlueprintCommand@34bdb859
org.apache.aries.blueprint - 0.3.0 | Creating listeners
org.apache.aries.blueprint - 0.3.0 | Listeners created: []
org.apache.aries.blueprint - 0.3.0 | Calling listeners for initial
service registration
org.apache.aries.blueprint - 0.3.0 | Method entry: getService, args
org.apache.karaf.shell.console.commands.BlueprintCommand@34bdb859
org.apache.aries.blueprint - 0.3.0 | Instantiating component shell-181
org.apache.aries.blueprint - 0.3.0 | Instantiating component
blueprintBundleContext

Up to this point the log output is equal with both frameworks (see below).

What might be the problem?

Stefan

osgi.test - 0.0.1 | BundleEvent INSTALLED
org.apache.aries.blueprint - 0.3.0 | Retrieving service for bundle
org.apache.karaf.shell.console_2.2.0 [22] and service registration
{org.apache.karaf.shell.console.CompletableFunction,
org.apache.felix.service.command.Function}={osgi.command.function=start,
osgi.command.scope=osgi, service.id=152}
org.apache.aries.blueprint - 0.3.0 | Creating service instance
org.apache.aries.blueprint - 0.3.0 | Service created:
org.apache.karaf.shell.console.commands.BlueprintCommand@1648ff68
org.apache.aries.blueprint - 0.3.0 | Creating listeners
org.apache.aries.blueprint - 0.3.0 | Listeners created: []
org.apache.aries.blueprint - 0.3.0 | Calling listeners for initial
service registration
org.apache.aries.blueprint - 0.3.0 | Method entry: getService, args
org.apache.karaf.shell.console.commands.BlueprintCommand@1648ff68
org.apache.aries.blueprint - 0.3.0 | Instantiating component shell-135
org.apache.aries.blueprint - 0.3.0 | Instantiating component
blueprintBundleContext
org.apache.aries.blueprint - 0.3.0 | Scanning bundle osgi.test for
blueprint application
osgi.test - 0.0.1 | BundleEvent RESOLVED
org.apache.aries.blueprint - 0.3.0 | Found blueprint application in
bundle osgi.test with paths:
[bundleentry://42.fwk572511714/OSGI-INF/blueprint/commands.xml]
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state Unknown
org.apache.aries.blueprint - 0.3.0 | Sending blueprint container event
BlueprintEvent[type=CREATING] for bundle osgi.test
org.apache.karaf.shell.osgi - 2.2.0 | Blueprint app state changed to
Creating for bundle 42
osgi.test - 0.0.1 | BundleEvent STARTED
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state WaitForNamespaceHandlers
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state Populated
org.apache.aries.blueprint - 0.3.0 | Tracking service references: []
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state WaitForInitialReferences
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state InitialReferencesSatisfied
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state WaitForInitialReferences2
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state Create
org.apache.aries.blueprint - 0.3.0 | Registering service shell-182 with
interfaces [org.apache.karaf.shell.console.CompletableFunction,
org.apache.felix.service.command.Function] and properties
{osgi.command.function=world, osgi.command.scope=hello}
osgi.test - 0.0.1 | ServiceEvent REGISTERED
org.apache.aries.blueprint - 0.3.0 | Instantiating components:
[blueprintContainer, blueprintBundle, blueprintBundleContext,
blueprintConverter]
osgi.test - 0.0.1 | ServiceEvent REGISTERED
org.apache.aries.blueprint - 0.3.0 | Sending blueprint container event
BlueprintEvent[type=CREATED] for bundle osgi.test
org.apache.karaf.shell.osgi - 2.2.0 | Blueprint app state changed to
Created for bundle 42
org.apache.aries.blueprint - 0.3.0 | Running blueprint container for
bundle osgi.test in state Created






Reply via email to