I guess that you have a bundle providing MyService interface (Export-Package) and another bundle that import the package containing the interface (Import-Package).

Check if you don't have MyService two times (embedded instead of imported).

Regards
JB

On 08/11/2014 03:09 PM, Milan Tomic wrote:
Hi Jean,

Yes, MyService is an interface.

No, I am not using blueprint, but I will search for some example now. :)

Thank you
Milan


On Monday, August 11, 2014 3:05 PM, Jean-Baptiste Onofré
<[email protected]> wrote:


Hi Milan,

MyService is the interface ?

You register the service using blueprint ?

Regards
JB

On 08/11/2014 02:55 PM, Milan Tomic wrote:
 >
 > Thank you very much for your answers. Due to my bug my Activator didn't
 > activated my service and that was causing problems.
 >
 > Now I got this exception:
 >
 > ClassCastException: Proxy68687b14_9ba8_4734_b559_b199ee1ac482 cannot be
 > cast to myPackage.MyService
 >
 > when I do this:
 >
 > MyService myService = (MyService) ic.lookup("osgi:service/" +
 > MyService.class.getName());
 >
 > what could be a problem?
 >
 > Thank you in advance,
 > Milan
 >
 >
 >
 >
 >
 > On Monday, August 11, 2014 2:50 PM, Milan Tomic <[email protected]
<mailto:[email protected]>>
 > wrote:
 >
 >
 >
 > Oh :) I didn't noticed that I sent this only to you :) I wanted to send
 > it to the whole user mailing list. Sorry and discard this email because
 > it is solved already.
 >
 > Br, Milan
 >
 >
 > On Monday, August 11, 2014 9:39 AM, Milan Tomic <[email protected]
<mailto:[email protected]>>
 > wrote:
 >
 >
 >
 > Thank you very much for your responses.
 >
 > Do I have to register OSGi service with JNDI or all OSGi services
 > areautoregistered? I am trying this:
 >
 > MyService myService = (MyService) ic.lookup("osgi:service/" +
 > MyService.class.getName());
 >
 > and I got this exception:
 >
 > javax.naming.NameNotFoundException: osgi:service/mypackage.MyService
 >
 > I have already instaled feature:install jndi
 >
 > Thank you in advance,
 > Milan
 >
 >
 >
 > On Saturday, August 9, 2014 10:03 AM, "[email protected]
<mailto:[email protected]>"
 > <[email protected] <mailto:[email protected]>> wrote:
 >
 >
 > Hello Milan,
 >
 > You don't say which tutorial you followed: if you use Eclipse then I
 > suggest you take a look at <http://bndtools.org/tutorial.html>. Step 6
 > won't work for you because it's designed for a different shell than the
 > one Karaf uses by default, but you should learn something from the
earlier
 > steps.
 >
 >  > public interface ParserService {
 >  >    String parse(String s);
 >  > }
 >  >
 >  > public class ParserImpl implements ParserService {
 >  >    public String parse(String s) {
 >  >        return s.replaceAll("AA", "BB");
 >  >    }
 >  >  }
 >
 > I hope these are two separate files, BTW otherwise I will have to
send you
 > to bed without any supper. :)
 >
 >
 >  > Now I have no idea how to call this service from outside of Karaf.
Let's
 >  > say from an Servlet running inside some Tomcat on the same Windows
Server
 >  > maching. So, how do you create OSGi/Karaf client app?
 >
 >
 > At this stage you can't even call the service from *inside* Karaf,
because
 > you didn't register it with the framework. There are many ways to do
this,
 > from the painstakingly manual to the mysteriously magical - the
@Component
 > annotation falls into the latter category, so once you have it
working you
 > might like to read up on "bnd" and "scr" to see how the magic works.
 >
 > If you want to present a web interface then the easiest way is to install
 > the Karaf "web" feature and have your module register a service which
 > implements HttpServlet and has a property called "alias". This will
 > automatically be picked up by something called PAX Web, which will
wire it
 > into Jetty for you.
 >
 > HTH, Chris

 >
 >
 >
 >
 >
 >
 >
 >
 >

--
Jean-Baptiste Onofré
[email protected] <mailto:[email protected]>
http://blog.nanthrax.net <http://blog.nanthrax.net/>
Talend - http://www.talend.com <http://www.talend.com/>


--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to