Return-Path: X-Original-To: apmail-karaf-user-archive@minotaur.apache.org Delivered-To: apmail-karaf-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 37F211872A for ; Tue, 5 Jan 2016 20:30:45 +0000 (UTC) Received: (qmail 90231 invoked by uid 500); 5 Jan 2016 20:30:45 -0000 Delivered-To: apmail-karaf-user-archive@karaf.apache.org Received: (qmail 90186 invoked by uid 500); 5 Jan 2016 20:30:45 -0000 Mailing-List: contact user-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@karaf.apache.org Delivered-To: mailing list user@karaf.apache.org Received: (qmail 90176 invoked by uid 99); 5 Jan 2016 20:30:44 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2016 20:30:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 860E7C0EDD for ; Tue, 5 Jan 2016 20:30:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.021 X-Spam-Level: X-Spam-Status: No, score=-0.021 tagged_above=-999 required=6.31 tests=[RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 6SNHhzrRa7fr for ; Tue, 5 Jan 2016 20:30:37 +0000 (UTC) Received: from 2.mo7.mail-out.ovh.net (2.mo7.mail-out.ovh.net [87.98.143.68]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 991ED201BC for ; Tue, 5 Jan 2016 20:30:37 +0000 (UTC) Received: from mail377.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 798ACFF881C for ; Tue, 5 Jan 2016 21:30:25 +0100 (CET) Received: from RCM-78.199.223.181 (localhost [127.0.0.1]) by mail377.ha.ovh.net (Postfix) with ESMTPA id 5FB4D360060 for ; Tue, 5 Jan 2016 21:30:25 +0100 (CET) Received: from qtf31-1-78-199-223-181.fbx.proxad.net ([78.199.223.181]) by ssl0.ovh.net with HTTP (HTTP/1.1 POST); Tue, 05 Jan 2016 21:30:25 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 05 Jan 2016 21:30:25 +0100 From: ben@petinou.fr To: user@karaf.apache.org Subject: Null service in Karaf command Message-ID: X-Sender: ben@petinou.fr User-Agent: Roundcube Webmail/1.1.3 X-Originating-IP: 78.199.223.181 X-Webmail-UserID: ben@petinou.fr X-Ovh-Tracer-Id: 2873578041332080394 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekiedrieelgddufeehucetufdoteggodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecu Hi everyone, I'm trying to create a Karaf Command that uses one of my services (via Declarative Services configured with maven-bundle-plugin). Here is my Karaf command: @Command(scope = "myscope", name = "myCmd", description = "desc") @Service @Component(immediate = true) public class MyCmd implements Action { /** Reference to the model. */ private Model model; @Override public Object execute() throws Exception { System.out.println("Model: " + model); return null; } @Reference public void setModel(final Model modelToSet) { System.out.println("MyCmd.setModel: " + modelToSet); model = modelToSet; } public void unsetModel(final Model modelToSet) { System.out.println("MyCmd.unsetModel"); model = null; } } When I start Karaf, I have the following output in the console: MyCmd.setModel: ModelImpl@23623746 But when I call the command, the model is null... karaf@root()> myscope:myCmd Model: null I guess there is something wrong with how Karaf creates the commands (I guess the commands are instantiated each time they are called from the console). I just declared the ModelImpl class with @Component (and it implements my Model interface). How could I make it work? Kind regards, Ben