Hello Alex, I am by no means an OSGi expert either, but if I am understanding your code correctly, you are registering the 'ServiceImpl' as a service by it's class name, but asking for the HelloInterface service in your client. If ServiceImpl implements HelloInterface, then try registering the ServiceImpl object as a HelloInterface service:
context.registerService( HelloInterface.class.getName(), x, props ); ~Matt -----Original Message----- From: Imóveis Nacionais [mailto:[email protected]] Sent: Tuesday, February 12, 2013 7:21 AM To: [email protected] Subject: Very beginner question: maven, netbeans. Implementing a client.... Hi all, my first time I am a very new beginner in osgi and am stating with netbeans maven and felix I created the project MyOSGi as a Maven OSGi bundle. In the src folder I have the com.mycompany.myosgi package which has the activator and Serviceimpl In the src folder i have another package called com.mycompany.myosgi.ServiceInterface which has the interface: public interface HelloInterface { public void HelloToYou(); } Here the activator: package com.mycompany.myosgi; import java.util.Hashtable; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class Activator implements BundleActivator { ServiceImpl x =null; public void start(BundleContext context) throws Exception { x =new ServiceImpl(); Hashtable props = new Hashtable(); props.put("description", "This an service impl object"); context.registerService(ServiceImpl.class.getName(), x, props); System.out.println("Service was registered. Hello OSGi World"); } public void stop(BundleContext context) throws Exception { System.out.println("Goodbye OSGi World"); } } I can compile it without errors and start it in the felix framework: g! install file:/C:/PROJS/OSGi/felix-framework-4.0.3/MyOSGi-1.0-SNAPSHOT.jar Bundle ID: 25 g! start 25 Ex1: Service of type com.mycompany.myosgi.ServiceImpl registered. Service was registered. Hello OSGi World g! Then I created another bundle project called MyOSGiClient which has in the src folder the com.mycompany.myosgiclient package which has the activator class: package com.mycompany.myosgiclient; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import com.mycompany.myosgi.ServiceInterface.HelloInterface; public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { ServiceReference sr = context.getServiceReference(HelloInterface.class.getName()); if(sr != null) { HelloInterface http = (HelloInterface)context.getService(sr); if(http != null) { http.HelloToYou(); } } } public void stop(BundleContext context) throws Exception { // TODO add deactivation code here } } But the import com.mycompany.myosgi.ServiceInterface.HelloInterface; gives me error because it cant find it On the "server bundle" I exported both packages. How can I access server bundle interface type during compile time? Thanks a lot Alex - This message is intended only for the addressee and may contain information that is company confidential or privileged. Any technical data in this message may be exported only in accordance with the U.S. International Traffic in Arms Regulations (22 CFR Parts 120-130) or the Export Administration Regulations (15 CFR Parts 730-774). Unauthorized use is strictly prohibited and may be unlawful. If you are not the intended recipient, or the person responsible for delivering to the intended recipient, you should not read, copy, disclose or otherwise use this message. If you have received this email in error, please delete it, and advise the sender immediately. - --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

