felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard S. Hall" <he...@ungoverned.org>
Subject Re: serviceChanged handler never called
Date Wed, 13 Feb 2013 15:52:52 GMT
Well, I took your bundle and deleted what I had to to get it to compile 
(e.g., your upnp stuff) and it still sort of works for me except your 
listener gets an NPE since it is trying to get the objectClass property 
using the name "description":

g! lb
START LEVEL 1
    ID|State      |Level|Name
     0|Active     |    0|System Bundle (4.3.0.SNAPSHOT)
     1|Resolved   |    1|Apache Felix Bundle Repository (1.6.6)
     2|Active     |    1|Apache Felix Gogo Command (0.12.0)
     3|Active     |    1|Apache Felix Gogo Runtime (0.10.0)
     4|Active     |    1|Apache Felix Gogo Shell (0.10.0)
     8|Active     |    1|MyBundleClientListen OSGi Bundle (1.0.0.SNAPSHOT)
g! start 1
serviceChanged called
LISTAGEM DE PROPS:
[objectClass, service.id]
ERROR: Bundle com.mycompany.MyBundleClientListen [8] EventDispatcher: 
Error during dispatch. (java.lang.NullPointerException)
java.lang.NullPointerException
     at 
com.mycompany.mybundleclientlisten.Activator.serviceChanged(Activator.java:55)


-> richard

On 2/13/13 09:42 , Imóveis Nacionais wrote:
> I did not changed manifest.mf. I think netbeans and maven do that.
>
> Here the manifest contents:
>
>
> Manifest-Version: 1.0
> Export-Package: com.mycompany.mybundleclientlisten;uses:="com.mycompan
>  y.mybundleserver.serviceinterface,org.osgi.framework"
> Built-By: ncosta
> Tool: Bnd-1.15.0
> Bundle-Name: MyBundleClientListen OSGi Bundle
> Created-By: Apache Maven Bundle Plugin
> Bundle-Version: 1.0.0.SNAPSHOT
> Build-Jdk: 1.7.0_11
> Bnd-LastModified: 1360759133638
> Bundle-ManifestVersion: 2
> Bundle-Activator: com.mycompany.mybundleclientlisten.Activator
> Import-Package: com.mycompany.mybundleserver.serviceinterface,org.osgi
>  .framework;version="[1.5,2)"
> Bundle-SymbolicName: com.mycompany.MyBundleClientListen
>
>
> Alex
> (By the way, I also zipped the whole project)
>
>
>
> On Wed, Feb 13, 2013 at 2:30 PM, Richard S. Hall <heavy@ungoverned.org 
> <mailto:heavy@ungoverned.org>> wrote:
>
>     There is something going wrong in your setup. Are you sure your
>     monitoring bundle is getting activated? Did you specify
>     Bundle-Activator in your manifest?
>
>     I created a bundle like yours and it worked fine for me:
>
>     g! lb
>     START LEVEL 1
>        ID|State      |Level|Name
>         0|Active     |    0|System Bundle (4.3.0.SNAPSHOT)
>         1|Active     |    1|Apache Felix Bundle Repository (1.6.6)
>         2|Active     |    1|Apache Felix Gogo Command (0.12.0)
>         3|Active     |    1|Apache Felix Gogo Runtime (0.10.0)
>         4|Active     |    1|Apache Felix Gogo Shell (0.10.0)
>         7|Active     |    1|service.listener.text (0.0.0)
>     g! stop 1
>     **serviceChanged called
>     **serviceChanged called
>     g! start 1
>     **serviceChanged called
>     **serviceChanged called
>     g!
>
>     -> richard
>
>
>     On 2/13/13 09:07 , Imóveis Nacionais wrote:
>
>         yes, I can install the related 'client bundle' and call the
>         service on the
>         server bundle:
>
>
>
>                  ServiceReference sr  =
>         context.getServiceReference(upnp.class.getName());
>                  if(sr != null)
>                  {
>                    upnp x = (upnp)context.getService(sr);
>                    if(x != null)
>                    {
>                          System.out.println("Vai chamar o serviço
>         HelloToYou...");
>                          int n=x.GetNumber();
>                          System.out.println("Vai libertar serviço
>         HelloToYou... "+n);
>                          context.ungetService(sr);
>
>         This code from related 'client' bundle works.
>
>         I also checked the export packages of the used server bundle
>         and both
>         interface and bundle are marked for exportation
>
>         Alex
>
>
>
>         On Wed, Feb 13, 2013 at 1:49 PM, Richard S. Hall
>         <heavy@ungoverned.org <mailto:heavy@ungoverned.org>>wrote:
>
>             Are you sure the server bundle is providing its service?
>
>             -> richard
>
>
>             On 2/13/13 08:36 , Imóveis Nacionais wrote:
>
>                 Hi
>                 I am trying to play with service events in a client
>                 bundle in order to be
>                 notified when other bundles are registered.
>
>                 So, I created a simple maven osgi bundler just with an
>                 activator class.
>
>                 public class Activator implements BundleActivator,
>                 ServiceListener
>                 {
>
>                       public void start(BundleContext context) throws
>                 Exception
>                       {
>                               System.out.println("Client bundle
>                 initializing on start
>                 method...");
>
>                               context.addServiceListener(**this);
>
>
>
>                       public void stop(BundleContext context) throws
>                 Exception
>                       {
>                           context.removeServiceListener(**this);
>                       }
>
>                       public void serviceChanged(ServiceEvent event)
>                       {
>                           System.out.println("**serviceChanged called");
>
>                       }
>
>                 Then, in the gogo shell of felix I installed this
>                 client bundle and
>                 started
>                 it. Then I installed other (server) bundle and started
>                 it but the
>                 serviceChanged handler is never called. Why?
>
>                 Thanks a lot
>
>                 Alex
>
>
>             ------------------------------**------------------------------**---------
>             To unsubscribe, e-mail:
>             users-unsubscribe@felix.**apache.org
>             <http://apache.org><users-unsubscribe@felix.apache.org
>             <mailto:users-unsubscribe@felix.apache.org>>
>
>             For additional commands, e-mail:
>             users-help@felix.apache.org
>             <mailto:users-help@felix.apache.org>
>
>
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>     <mailto:users-unsubscribe@felix.apache.org>
>     For additional commands, e-mail: users-help@felix.apache.org
>     <mailto:users-help@felix.apache.org>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message