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
