On 5/18/09 4:04 PM, Moloney, Tim M wrote:
I've attached my example project.  To build it just run 'mvn install'.
To run it from the command line, run 'RunFooFromOsgi'.  To run it within
Eclipse, import the project, then run fooOsgi.  RunFooFromMain (command
line) and fooMain (Eclipse) run the example service provider
successfully outside of Felix.

If I run my example code from the command line (RunFooFromOsgi), no
service providers are found.

Is this the behavior you are expecting?

If I run my example code from within Eclipse, I get the following:

I believe Eclipse boot delegates every package, so your bundles may not be seeing what you expect them to.

-> richard
Welcome to Felix.
=================

->  In com.example.foo.osgi.Activator.start():
ERROR: Error starting file:target/com.example.foo.osgi-0.1.0.jar
(org.osgi.framework.BundleException: Activator start error in bundle
com.example.foo.osgi [5].)
java.util.ServiceConfigurationError: com.example.foo.spi.Foo: Provider
com.example.foo.impl.FooImpl could not be instantiated:
java.lang.ClassCastException
        at java.util.ServiceLoader.fail(ServiceLoader.java:207)
        at java.util.ServiceLoader.access$100(ServiceLoader.java:164)
        at
java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
        at com.example.foo.spi.FooFactory.getFoo(FooFactory.java:17)
        at com.example.foo.osgi.Activator.start(Activator.java:17)
        at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction
.java:589)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1458)
        at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:984)
        at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:263)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException
        at java.lang.Class.cast(Class.java:2990)
        at
java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)
        ... 8 more


Tim Moloney                            The reasonable man adapts himself
to
ManTech Real-time Systems Laboratory   the world; the unreasonable one
persists
2015 Cattlemen Road                    in trying to adapt the world to
himself.
Sarasota, FL  34232                    Therefore all progress depends on
the
(941) 377-6775 x208                    unreasonable man. - George
Bernard Shaw


-----Original Message-----
From: Richard S. Hall [mailto:he...@ungoverned.org]
Sent: Monday, May 18, 2009 10:11
To: users@felix.apache.org
Subject: Re: ServiceLoader and OSGi?

On 5/18/09 9:31 AM, Moloney, Tim M wrote:
I have a very simple service provider that works outside of OSGi.

I tried using it in Felix but it fails with a ClassCastException.

Is this somehow related to the different class loaders in
the different
bundles?

Probably.

Any suggestions on how to get past this?

Not enough information to say.

->  richard

Thanks.


Tim Moloney             The  reasonable  man adapts  himself  to
MRSL                    the world; the unreasonable one persists
2015 Cattlemen Road     in trying to adapt the world to himself.
Sarasota, FL  34232     Therefore  all progress  depends on  the
(941) 377-6775 x208     unreasonable man.    George Bernard Shaw




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org


------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org

Reply via email to