You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by ellirael <el...@mail.ru> on 2015/08/26 12:17:16 UTC

Karaf 4 command bundle using service

I've got 2 bundles. One registers the service via blueprint. And another one
is command bundle. Command bundle injects registered service with command
lifecycle annotation. The problem is when I update service bundle command
disappears until I restart Karaf.

package biz.lorien.niichi.command;

import biz.lorien.niichi.api.model.entity.Player;
import biz.lorien.niichi.api.service.PlayerService;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;

@Service
@Command(scope = "niichi", name = "add-player")
public class AddPlayerCommand implements Action {

    @Reference
    private PlayerService playerService;

    @Argument(index = 0, name = "id", required = true, multiValued = false)
    private String id;

    @Argument(index = 1, name = "name", required = true, multiValued =
false)
    private String name;

    @Override
    public Object execute() throws Exception {
        Player player = new Player();
        player.setId(id);
        player.setName(name);
        player.setNiichi(true);
        playerService.addPlayer(player);
        return player;
    }

}




--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4 command bundle using service

Posted by ellirael <el...@mail.ru>.
Restarting command bundle doesn't help.
Uninstalling and installing command bundle helps.

BTW, why do I keep getting that nasty EclipseLink warning?



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042226.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4 command bundle using service

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You are right: I reproduce the issue on Cellar.

If I stop and restart the cellar-hazelcast bundle (providing 
ClusterManager and GroupManager services), the shell commands disappear 
as the services are not reinjected.

I created a Jira and gonna fix that:

https://issues.apache.org/jira/browse/KARAF-3966

Regards
JB

On 09/01/2015 10:24 AM, ellirael wrote:
> karaf@root()> service:list PlayerService
> [biz.lorien.niichi.api.service.PlayerService]
> ---------------------------------------------
>   osgi.service.blueprint.compname = playerService
>   service.bundleid = 139
>   service.id = 168
>   service.scope = bundle
> Provided by :
>   Lorien Niichi API (139)
>
> karaf@root()>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042224.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 4 command bundle using service

Posted by ellirael <el...@mail.ru>.
karaf@root()> service:list PlayerService
[biz.lorien.niichi.api.service.PlayerService]
---------------------------------------------
 osgi.service.blueprint.compname = playerService
 service.bundleid = 139
 service.id = 168
 service.scope = bundle
Provided by :
 Lorien Niichi API (139)

karaf@root()>



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042224.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4 command bundle using service

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Can you check the player service is still there (using ls command) ?

Regards
JB

On 09/01/2015 10:18 AM, ellirael wrote:
> I mean command disappears.
>
> 139 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi API
> 140 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi Command
> karaf@root()> niichi
> niichi               niichi:add-player
> karaf@root()> niichi:add-player
> Error executing command niichi:add-player: argument id is required
> karaf@root()> update 139
> [EL Warning]: 2015-09-01 12:17:41.524--session_manager_no_partition
> [EL Warning]: 2015-09-01 12:17:46.335--session_manager_no_partition
> karaf@root()> niichi:add-player
> Command not found: niichi:add-player
> karaf@root()>
>
> Command bundle is active afte updating service bundle.
> 139 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi API
> 140 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi Command
> karaf@root()>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042222.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 4 command bundle using service

Posted by ellirael <el...@mail.ru>.
I mean command disappears.

139 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi API
140 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi Command
karaf@root()> niichi
niichi               niichi:add-player
karaf@root()> niichi:add-player
Error executing command niichi:add-player: argument id is required
karaf@root()> update 139
[EL Warning]: 2015-09-01 12:17:41.524--session_manager_no_partition
[EL Warning]: 2015-09-01 12:17:46.335--session_manager_no_partition
karaf@root()> niichi:add-player
Command not found: niichi:add-player
karaf@root()>

Command bundle is active afte updating service bundle.
139 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi API
140 | Active |  80 | 1.0.0.SNAPSHOT          | Lorien Niichi Command
karaf@root()>



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042222.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4 command bundle using service

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

you mean when the playerService is unregister and register again, the 
command doesn't seem to be updated and stop ?

Regards
JB

On 08/26/2015 12:17 PM, ellirael wrote:
> I've got 2 bundles. One registers the service via blueprint. And another one
> is command bundle. Command bundle injects registered service with command
> lifecycle annotation. The problem is when I update service bundle command
> disappears until I restart Karaf.
>
> package biz.lorien.niichi.command;
>
> import biz.lorien.niichi.api.model.entity.Player;
> import biz.lorien.niichi.api.service.PlayerService;
> import org.apache.karaf.shell.api.action.Action;
> import org.apache.karaf.shell.api.action.Argument;
> import org.apache.karaf.shell.api.action.Command;
> import org.apache.karaf.shell.api.action.lifecycle.Reference;
> import org.apache.karaf.shell.api.action.lifecycle.Service;
>
> @Service
> @Command(scope = "niichi", name = "add-player")
> public class AddPlayerCommand implements Action {
>
>      @Reference
>      private PlayerService playerService;
>
>      @Argument(index = 0, name = "id", required = true, multiValued = false)
>      private String id;
>
>      @Argument(index = 1, name = "name", required = true, multiValued =
> false)
>      private String name;
>
>      @Override
>      public Object execute() throws Exception {
>          Player player = new Player();
>          player.setId(id);
>          player.setName(name);
>          player.setNiichi(true);
>          playerService.addPlayer(player);
>          return player;
>      }
>
> }
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 4 command bundle using service

Posted by ellirael <el...@mail.ru>.
I need to say that it is appearing/disappearing bug. Sometimes I have it.
Sometimes I have not.
I cannot understand a reason or prerequisites.



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042313.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4 command bundle using service

Posted by ellirael <el...@mail.ru>.
Service is present.

I have installed different verision of vaadin - 7.5.4 instead of 7.4.5. It
is strange but the problem is gone.



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042251.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4 command bundle using service

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Are you sure the Entity (niichi) service is really there ?

Regards
JB

On 09/01/2015 03:41 PM, ellirael wrote:
> In my case command disappearing is very stable.
> There is a log on "restart 139" command:
>
> ***** diffs k1.log, k2.log
> 2015-09-01 17:37:32,228 | INFO  | nsole user karaf | BlueprintExtender
> | 12 - org.apache.aries.blueprint.core -
> 1.4.3 | Destroying BlueprintContainer for bundle biz.lorien.niichi.api
> 2015-09-01 17:37:32,229 | INFO  | nsole user karaf | CommandExtension
> | 43 - org.apache.karaf.shell.core - 4.0.
> 1 | Unregistering commands for bundle
> biz.lorien.niichi.command/1.0.0.SNAPSHOT
> 2015-09-01 17:37:32,232 | INFO  | nsole user karaf |
> PersistenceBundleTracker         | 114 - org.apache.aries.jpa.container -
> 2.1.0 | removing persistence units for biz.lorien.niichi.api UNINSTALLED
> 2015-09-01 17:37:32,233 | INFO  | nsole user karaf |
> PersistenceProviderTracker       | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Lost provider for niichi
> org.eclipse.persistence.jpa.PersistenceProvider
> 2015-09-01 17:37:32,233 | INFO  | nsole user karaf | DataSourceTracker
> | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Lost DataSource for niichi
> osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=niichi)
> 2015-09-01 17:37:35,303 | INFO  | nsole user karaf |
> PersistenceBundleTracker         | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Found persistence unit niichi in bundle biz.lorien.niichi.api with
> provider org.eclipse.persistence.jpa.PersistenceProv
> ider.
> 2015-09-01 17:37:35,313 | INFO  | nsole user karaf |
> PersistenceProviderTracker       | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Found provider for niichi
> org.eclipse.persistence.jpa.PersistenceProvider
> 2015-09-01 17:37:35,353 | INFO  | nsole user karaf | JPAWeavingHook
> | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Adding transformer
> org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver
> 2015-09-01 17:37:35,356 | INFO  | nsole user karaf | DataSourceTracker
> | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Tracking DataSource for punit niichi with filter
> (&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=niichi))
> 2015-09-01 17:37:35,357 | INFO  | nsole user karaf | DataSourceTracker
> | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Found DataSource for niichi
> osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=niichi)
> 2015-09-01 17:37:35,361 | INFO  | ies.jpa.niichi]) | ManagedEMF
> | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Registering EntityManagerFactory for persistence unit niichi
> 2015-09-01 17:37:35,462 | INFO  | ies.jpa.niichi]) | JPAWeavingHook
> | 114 - org.apache.aries.jpa.container -
> 2.1.0 | Adding transformer
> org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver
> *****
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042249.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 4 command bundle using service

Posted by ellirael <el...@mail.ru>.
In my case command disappearing is very stable.
There is a log on "restart 139" command:

***** diffs k1.log, k2.log
2015-09-01 17:37:32,228 | INFO  | nsole user karaf | BlueprintExtender               
| 12 - org.apache.aries.blueprint.core - 
1.4.3 | Destroying BlueprintContainer for bundle biz.lorien.niichi.api
2015-09-01 17:37:32,229 | INFO  | nsole user karaf | CommandExtension                
| 43 - org.apache.karaf.shell.core - 4.0.
1 | Unregistering commands for bundle
biz.lorien.niichi.command/1.0.0.SNAPSHOT
2015-09-01 17:37:32,232 | INFO  | nsole user karaf |
PersistenceBundleTracker         | 114 - org.apache.aries.jpa.container - 
2.1.0 | removing persistence units for biz.lorien.niichi.api UNINSTALLED
2015-09-01 17:37:32,233 | INFO  | nsole user karaf |
PersistenceProviderTracker       | 114 - org.apache.aries.jpa.container - 
2.1.0 | Lost provider for niichi
org.eclipse.persistence.jpa.PersistenceProvider
2015-09-01 17:37:32,233 | INFO  | nsole user karaf | DataSourceTracker               
| 114 - org.apache.aries.jpa.container - 
2.1.0 | Lost DataSource for niichi
osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=niichi)
2015-09-01 17:37:35,303 | INFO  | nsole user karaf |
PersistenceBundleTracker         | 114 - org.apache.aries.jpa.container - 
2.1.0 | Found persistence unit niichi in bundle biz.lorien.niichi.api with
provider org.eclipse.persistence.jpa.PersistenceProv
ider.
2015-09-01 17:37:35,313 | INFO  | nsole user karaf |
PersistenceProviderTracker       | 114 - org.apache.aries.jpa.container - 
2.1.0 | Found provider for niichi
org.eclipse.persistence.jpa.PersistenceProvider
2015-09-01 17:37:35,353 | INFO  | nsole user karaf | JPAWeavingHook                  
| 114 - org.apache.aries.jpa.container - 
2.1.0 | Adding transformer
org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver
2015-09-01 17:37:35,356 | INFO  | nsole user karaf | DataSourceTracker               
| 114 - org.apache.aries.jpa.container - 
2.1.0 | Tracking DataSource for punit niichi with filter
(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=niichi))
2015-09-01 17:37:35,357 | INFO  | nsole user karaf | DataSourceTracker               
| 114 - org.apache.aries.jpa.container - 
2.1.0 | Found DataSource for niichi
osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=niichi)
2015-09-01 17:37:35,361 | INFO  | ies.jpa.niichi]) | ManagedEMF                      
| 114 - org.apache.aries.jpa.container - 
2.1.0 | Registering EntityManagerFactory for persistence unit niichi
2015-09-01 17:37:35,462 | INFO  | ies.jpa.niichi]) | JPAWeavingHook                  
| 114 - org.apache.aries.jpa.container - 
2.1.0 | Adding transformer
org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver
*****




--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042249.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4 command bundle using service

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
I just rechecked with the FeaturesService and actually, it works fine: 
the service is reinjected and the commands available again (I tested 
with cellar-feature command).

Do you have something in the log ?

Regards
JB

On 08/26/2015 12:17 PM, ellirael wrote:
> I've got 2 bundles. One registers the service via blueprint. And another one
> is command bundle. Command bundle injects registered service with command
> lifecycle annotation. The problem is when I update service bundle command
> disappears until I restart Karaf.
>
> package biz.lorien.niichi.command;
>
> import biz.lorien.niichi.api.model.entity.Player;
> import biz.lorien.niichi.api.service.PlayerService;
> import org.apache.karaf.shell.api.action.Action;
> import org.apache.karaf.shell.api.action.Argument;
> import org.apache.karaf.shell.api.action.Command;
> import org.apache.karaf.shell.api.action.lifecycle.Reference;
> import org.apache.karaf.shell.api.action.lifecycle.Service;
>
> @Service
> @Command(scope = "niichi", name = "add-player")
> public class AddPlayerCommand implements Action {
>
>      @Reference
>      private PlayerService playerService;
>
>      @Argument(index = 0, name = "id", required = true, multiValued = false)
>      private String id;
>
>      @Argument(index = 1, name = "name", required = true, multiValued =
> false)
>      private String name;
>
>      @Override
>      public Object execute() throws Exception {
>          Player player = new Player();
>          player.setId(id);
>          player.setName(name);
>          player.setNiichi(true);
>          playerService.addPlayer(player);
>          return player;
>      }
>
> }
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 4 command bundle using service

Posted by ellirael <el...@mail.ru>.
Need help to resolve it.



--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065p4042219.html
Sent from the Karaf - User mailing list archive at Nabble.com.