Hi, I am trying to do some experiments of invoking another service in one bundler by searching for their references. My code and my pom.xml are as follows, it can pass the compilation however, it cannot be started after I deployed the jar file into the felix runtime.
However, the service my code invoked is correctly running at felix. Thanks a lot. The error message shows: -> [INFO] Started bridged http service [INFO] Started bridged http service [INFO] Http service whiteboard started [INFO] Detected extended HttpService. Filters enabled. *INFO * org.apache.felix.webconsole.internal.compendium.ComponentsServlet not enabled. Reason: Class org.apache.felix.scr.ScrService missing [INFO] Started jetty 6.1.x at port 8080 ERROR: Error starting file:/home/user/Desktop/jar/felix-framework-2.0.3/bundle/org.apache.felix.upnp.sample.workflow-0.1.0-SNAPSHOT.jar (org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.upnp.sample.workflow [93].) java.lang.NullPointerException: Specified service reference cannot be null. at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:320) at org.apache.felix.upnp.sample.workflow.Activator.doServiceRegistration(Activator.java:44) at org.apache.felix.upnp.sample.workflow.Activator.start(Activator.java:54) at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:661) at org.apache.felix.framework.Felix.activateBundle(Felix.java:1756) at org.apache.felix.framework.Felix.startBundle(Felix.java:1678) at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1124) at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264) at java.lang.Thread.run(Thread.java:619) =============== package org.apache.felix.upnp.sample.workflow; import java.util.Dictionary; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.apache.felix.upnp.sample.tv.*; public class Activator implements BundleActivator { static BundleContext context; private ServiceReference tvref; private void doServiceRegistration() { tvref = context.getServiceReference(TvDevice.class.getName()); TvDevice tvd = (TvDevice)context.getService(tvref); tvd.setMessage("hello world!"); } /** * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { Activator.context = context; doServiceRegistration(); } /** * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { context.ungetService(tvref); } } ================== <?xml version="1.0" encoding="UTF-8"?> <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/maven-v4_0_0.xsd"> <parent> <artifactId>felix-parent</artifactId> <groupId>org.apache.felix</groupId> <version>1.2.0</version> <relativePath>../../../pom/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.upnp.sample.workflow</artifactId> <packaging>bundle</packaging> <name>Apache Felix UPnP Sample workflow</name> <version>0.1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Bundle-Name>${pom.name}</Bundle-Name> <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor> <Bundle-Author> someone </Bundle-Author> <Bundle-Description>test workflow</Bundle-Description> <Bundle-SymbolicName>org.apache.felix.upnp.sample.workflow</Bundle-SymbolicName> <Bundle-Activator>org.apache.felix.upnp.sample.workflow.Activator</Bundle-Activator> <Private-Package>org.apache.felix.upnp.sample.workflow.*</Private-Package> <Import-Package>*</Import-Package> </instructions> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>${pom.groupId}</groupId> <artifactId>org.osgi.core</artifactId> <version>1.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>${pom.groupId}</groupId> <artifactId>org.osgi.compendium</artifactId> <version>1.0.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.upnp.sample.tv</artifactId> <version>0.2.0-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies> </project>