Yes, the Private-Package is what was messing things up, I believe.  That
setting is one that can get you in trouble.  What it does is it brings
anything on your classpath matching those patterns into your bundle and
doesn't export them.  If multiple people do that with a particular package,
then they will all have their own "flavor" of the classes in that package.
For example, in my osgi-sandbox project, I have this Private-Package
setting:

{local-packages],org.apache.commons.lang3

Then, my MANIFEST looks like:

Manifest-Version: 1.0

Bnd-LastModified: 1432042463489

Build-Jdk: 1.8.0_45

Build-Time: 2015-05-19T13:34:21Z

Built-By: jcarman

Bundle-DocURL: http://www.carmanconsulting.com

Bundle-ManifestVersion: 2

Bundle-Name: OSGi Sandbox :: Manifest Testing :: Private Package

Bundle-SymbolicName: com.carmanconsulting.sandbox.osgi.private-package

Bundle-Vendor: Carman Consulting, Inc.

Bundle-Version: 1.0.0.SNAPSHOT

Created-By: Apache Maven Bundle Plugin

Embed-Directory: lib

Export-Package: com.carmanconsulting.sandbox.osgi.manifest;version="1.0.

 0"

Implementation-Title: OSGi Sandbox :: Manifest Testing :: Private Packag

 e

Implementation-Vendor: Carman Consulting, Inc.

Implementation-Vendor-Id: com.carmanconsulting.sandbox.osgi

Implementation-Version: 1.0-SNAPSHOT

Import-Package:

 org.apache.commons.lang3.builder;version="[3.1,4)",

 org.apache.commons.lang3.exception;version="[3.1,4)",

 org.apache.commons.lang3.math;version="[3.1,4)",

 org.apache.commons.lang3.mutable;version="[3.1,4)",

 org.apache.commons.lang3.text.translate;version="[3.1,4)"

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"

Specification-Title: OSGi Sandbox :: Manifest Testing :: Private Package

Specification-Vendor: Carman Consulting, Inc.

Specification-Version: 1.0-SNAPSHOT

Tool: Bnd-2.3.0.201405100607


The jar file contains:


META-INF/MANIFEST.MF

META-INF/

META-INF/maven/

META-INF/maven/com.carmanconsulting.sandbox.osgi/

META-INF/maven/com.carmanconsulting.sandbox.osgi/private-package/

META-INF/maven/com.carmanconsulting.sandbox.osgi/private-package/pom.properties

META-INF/maven/com.carmanconsulting.sandbox.osgi/private-package/pom.xml

com/

com/carmanconsulting/

com/carmanconsulting/sandbox/

com/carmanconsulting/sandbox/osgi/

com/carmanconsulting/sandbox/osgi/manifest/

com/carmanconsulting/sandbox/osgi/manifest/ProductionClass.class

org/

org/apache/

org/apache/commons/

org/apache/commons/lang3/

org/apache/commons/lang3/AnnotationUtils$1.class

org/apache/commons/lang3/AnnotationUtils.class

org/apache/commons/lang3/ArrayUtils.class

org/apache/commons/lang3/BitField.class

org/apache/commons/lang3/BooleanUtils.class

org/apache/commons/lang3/CharEncoding.class

org/apache/commons/lang3/CharRange$1.class

org/apache/commons/lang3/CharRange$CharacterIterator.class

org/apache/commons/lang3/CharRange.class

org/apache/commons/lang3/CharSequenceUtils.class

org/apache/commons/lang3/CharSet.class

org/apache/commons/lang3/CharSetUtils.class

org/apache/commons/lang3/CharUtils.class

org/apache/commons/lang3/ClassUtils.class

org/apache/commons/lang3/EnumUtils.class

org/apache/commons/lang3/JavaVersion.class

org/apache/commons/lang3/LocaleUtils$SyncAvoid.class

org/apache/commons/lang3/LocaleUtils.class

org/apache/commons/lang3/ObjectUtils$Null.class

org/apache/commons/lang3/ObjectUtils.class

org/apache/commons/lang3/RandomStringUtils.class

org/apache/commons/lang3/Range$ComparableComparator.class

org/apache/commons/lang3/Range.class

org/apache/commons/lang3/SerializationException.class

org/apache/commons/lang3/SerializationUtils$ClassLoaderAwareObjectInputStream.class

org/apache/commons/lang3/SerializationUtils.class

org/apache/commons/lang3/StringEscapeUtils$CsvEscaper.class

org/apache/commons/lang3/StringEscapeUtils$CsvUnescaper.class

org/apache/commons/lang3/StringEscapeUtils.class

org/apache/commons/lang3/StringUtils$InitStripAccents.class

org/apache/commons/lang3/StringUtils.class

org/apache/commons/lang3/SystemUtils.class

org/apache/commons/lang3/Validate.class

On Tue, May 19, 2015 at 8:15 AM Jean-Baptiste Onofré <[email protected]>
wrote:

> Maybe you embedded the interface in each provider and consumer bundles ?
>
> Regards
> JB
>
> On 05/19/2015 02:12 PM, nino martinez wael wrote:
> > I must have messed something up while trying to make it work..
> >
> > On Tue, May 19, 2015 at 2:08 PM, James Carman
> > <[email protected]> wrote:
> >> Nice I made no customizations to the bundle plugin.  The settings in the
> >> parent pom reflect the default settings.
> >>
> >> On Tue, May 19, 2015 at 8:06 AM nino martinez wael
> >> <[email protected]> wrote:
> >>>
> >>> +1 for James helping out :) it is working now..
> >>>
> >>> On Tue, May 19, 2015 at 1:47 PM, James Carman
> >>> <[email protected]> wrote:
> >>>> Nino,
> >>>>
> >>>> https://github.com/nmwael/osgi2versions/pull/1
> >>>>
> >>>> Enjoy! :)
> >>>>
> >>>>
> >>>>
> >>>> On Tue, May 19, 2015 at 2:58 AM nino martinez wael
> >>>> <[email protected]> wrote:
> >>>>>
> >>>>> Okay to avoid further confusion, I've put up my project here :
> >>>>> https://github.com/nmwael/osgi2versions
> >>>>>
> >>>>> just run maven clean install -Dmaven.test.skip
> >>>>> then go in your favorite ide and run the test getHelloService() in
> >>>>> com.netdesign.osgi.examples.rest.endpoint located in the module
> >>>>> webservice_rest_test that should both give you the exception and
> bring
> >>>>> up an karaf with the installed non working bundles.
> >>>>>
> >>>>> I'll check the final manifests..
> >>>>>
> >>>>> On Mon, May 18, 2015 at 4:41 PM, Kevin Schmidt <[email protected]>
> >>>>> wrote:
> >>>>>> Seeing your two manifests would possibly reveal the issue.
> >>>>>>
> >>>>>> At its simplest, your bundle with the interface in it should have:
> >>>>>>
> >>>>>> Export-Package: com.netdesign.osgi.examples.rest.domain
> >>>>>>
> >>>>>> And the bundle with the service implementation should have:
> >>>>>>
> >>>>>> Import-Package: com.netdesign.osgi.examples.rest.domain
> >>>>>>
> >>>>>> Like others have said, just letting the Maven bundle plugin do all
> >>>>>> this
> >>>>>> for
> >>>>>> you is the easiest way to go.
> >>>>>>
> >>>>>> On Mon, May 18, 2015 at 7:27 AM, nino martinez wael
> >>>>>> <[email protected]> wrote:
> >>>>>>>
> >>>>>>> I Will try to manually do it.. Currently it runs in an pax exam
> >>>>>>> test..
> >>>>>>>
> >>>>>>> On May 18, 2015 3:29 PM, <[email protected]> wrote:
> >>>>>>>>
> >>>>>>>> Faced a similar ClassCastException some time back. Not sure
> whether
> >>>>>>>> it
> >>>>>>>> really make sense but just stating it here for your information. I
> >>>>>>>> had
> >>>>>>>> the
> >>>>>>>> service interfaces in one bundle (A), implementations in another
> >>>>>>>> bundle (B)
> >>>>>>>> and a number of consumers. Noticed the ClassCastException a few
> >>>>>>>> times
> >>>>>>>> if I
> >>>>>>>> issue a start command to A while starting B and consumers. This
> was
> >>>>>>>> happening with Karaf 3.0.0.
> >>>>>>>>
> >>>>>>>> -----Original Message-----
> >>>>>>>> From: nino martinez wael [mailto:[email protected]]
> >>>>>>>> Sent: Monday, May 18, 2015 6:48 PM
> >>>>>>>> To: [email protected]
> >>>>>>>> Subject: Re: Problems with Blueprint services
> >>>>>>>>
> >>>>>>>> Yes that is what I think i am doing.. If it helps I can clone my
> >>>>>>>> git
> >>>>>>>> to
> >>>>>>>> somewhere reachable? IT is a very basic example project just
> >>>>>>>> demonstrating a
> >>>>>>>> cxf rest front with 2 backend services with ranking.
> >>>>>>>>
> >>>>>>>> On Mon, May 18, 2015 at 3:11 PM,  <[email protected]> wrote:
> >>>>>>>>> You want to export the interface from the API bundle, import it
> >>>>>>>>> into
> >>>>>>>>> the service bundle, let BP and the Maven plugin take care of
> >>>>>>>>> exports
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Mon, May 18, 2015 at 7:09 AM, nino martinez wael
> >>>>>>>>> <[email protected]> wrote:
> >>>>>>>>>>
> >>>>>>>>>> I did use * exports initially but did change it.
> >>>>>>>>>>
> >>>>>>>>>> To
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> <Export-Service>com.netdesign.osgi.examples.rest.backendb.*</Export-S
> >>>>>>>>>> ervice> and commented out the export package part.
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> On Mon, May 18, 2015 at 2:55 PM, <[email protected]> wrote:
> >>>>>>>>>>> I’m guessing you are using * exports and the API and Impl
> >>>>>>>>>>> bundle
> >>>>>>>>>>> export the same interface.
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> On Mon, May 18, 2015 at 3:09 AM, nino martinez wael
> >>>>>>>>>>> <[email protected]> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>> Setter is correct:
> >>>>>>>>>>>>
> >>>>>>>>>>>> https://paste.apache.org/e5ld
> >>>>>>>>>>>>
> >>>>>>>>>>>> And BackendBImplement does implement the interface
> >>>>>>>>>>>>
> >>>>>>>>>>>> https://paste.apache.org/4pOv
> >>>>>>>>>>>>
> >>>>>>>>>>>> Heres the interface:
> >>>>>>>>>>>>
> >>>>>>>>>>>> package com.netdesign.osgi.examples.rest.domain;
> >>>>>>>>>>>>
> >>>>>>>>>>>> /**
> >>>>>>>>>>>> * Created by nmw on 14-05-2015.
> >>>>>>>>>>>> */
> >>>>>>>>>>>> public interface MessageProvider {
> >>>>>>>>>>>>
> >>>>>>>>>>>> String getMessage();
> >>>>>>>>>>>> }
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> I've probably made some simple mistake..Other than that im
> >>>>>>>>>>>> thinking of class loader conflicts..
> >>>>>>>>>>>>
> >>>>>>>>>>>> On Mon, May 18, 2015 at 10:03 AM, Jean-Baptiste Onofré
> >>>>>>>>>>>> <[email protected]>
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Check if the setter has the correct type. Check also if the
> >>>>>>>>>>>>> BackendBImplement implements MessageProvider.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Regards
> >>>>>>>>>>>>> JB
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On 05/18/2015 09:40 AM, nino martinez wael wrote:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Hi im having a little difficulty getting my services to
> >>>>>>>>>>>>>> get
> >>>>>>>>>>>>>> "injected"
> >>>>>>>>>>>>>> via a blueprint, the service are injected but when trying
> >>>>>>>>>>>>>> to
> >>>>>>>>>>>>>> use it, it fails with this exception:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Proxyac192a6f_60ad_44a3_8470_75b9a9054462 cannot be cast
> >>>>>>>>>>>>>> to
> >>>>>>>>>>>>>> com.netdesign.osgi.examples.rest.domain.MessageProvider
> >>>>>>>>>>>>>> java.lang.ClassCastException
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Service registration (in one bundle, interfaces in a
> >>>>>>>>>>>>>> shared
> >>>>>>>>>>>>>> bundle):
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> <bean id="backendB"
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> class="com.netdesign.osgi.examples.rest.backendb.BackendBImplementation"
> >>>>>>>>>>>>>> />
> >>>>>>>>>>>>>> <service id="serviceB" ref="backendB"
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> interface="com.netdesign.osgi.examples.rest.domain.MessageProvider"
> >>>>>>>>>>>>>> ranking="2"/>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Service consumer (another bundle) <bean id="htmlServer"
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> class="com.netdesign.osgi.examples.rest.endpoint.HtmlServer">
> >>>>>>>>>>>>>> <!-- <property name="messageProvider"
> >>>>>>>>>>>>>> ref="messageProviderService" /> --> </bean>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> <reference-list
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> interface="com.netdesign.osgi.examples.rest.domain.MessageProvi
> >>>>>>>>>>>>>> der"> <reference-listener ref="htmlServer"
> >>>>>>>>>>>>>> bind-method="setMessageProvider"/>
> >>>>>>>>>>>>>> </reference-list>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> <!--<reference id="messageProviderService"
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> interface="com.netdesign.osgi.examples.rest.domain.MessageProvi
> >>>>>>>>>>>>>> der"></reference>-->
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> I started using the commented out stuff since it was
> >>>>>>>>>>>>>> simpler,
> >>>>>>>>>>>>>> when fail I switched.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> --
> >>>>>>>>>>>>> Jean-Baptiste Onofré
> >>>>>>>>>>>>> [email protected]
> >>>>>>>>>>>>> http://blog.nanthrax.net
> >>>>>>>>>>>>> Talend - http://www.talend.com
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> --
> >>>>>>>>>>>> Best regards / Med venlig hilsen
> >>>>>>>>>>>> Nino Martinez
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> --
> >>>>>>>>>> Best regards / Med venlig hilsen
> >>>>>>>>>> Nino Martinez
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> Best regards / Med venlig hilsen
> >>>>>>>> Nino Martinez
> >>>>>>>> The information contained in this electronic message and any
> >>>>>>>> attachments
> >>>>>>>> to this message are intended for the exclusive use of the
> >>>>>>>> addressee(s)
> >>>>>>>> and
> >>>>>>>> may contain proprietary, confidential or privileged information.
> If
> >>>>>>>> you are
> >>>>>>>> not the intended recipient, you should not disseminate, distribute
> >>>>>>>> or
> >>>>>>>> copy
> >>>>>>>> this e-mail. Please notify the sender immediately and destroy all
> >>>>>>>> copies of
> >>>>>>>> this message and any attachments. WARNING: Computer viruses can be
> >>>>>>>> transmitted via email. The recipient should check this email and
> >>>>>>>> any
> >>>>>>>> attachments for the presence of viruses. The company accepts no
> >>>>>>>> liability
> >>>>>>>> for any damage caused by any virus transmitted by this email.
> >>>>>>>> www.wipro.com
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> Best regards / Med venlig hilsen
> >>>>> Nino Martinez
> >>>
> >>>
> >>>
> >>> --
> >>> Best regards / Med venlig hilsen
> >>> Nino Martinez
> >
> >
> >
>
> --
> Jean-Baptiste Onofré
> [email protected]
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Reply via email to