Alright thanks so much, andreas.

I'm trying to add this spring-dm "stuff" on my spring.xml file for bundleB.

I'll probably need some spring-dm stuff on karaf too (trying to understand if I 
have it as "features"  already or not).

That <osgi:service you put in comes from spring-osgi namespace (which I'll to 
add) right?


-----Original Message-----
From: Andreas Pieber [mailto:[email protected]] 
Sent: martedì 15 febbraio 2011 18:10
To: [email protected]; Marco Firrincieli
Subject: Re: spring injected bean cannot be found

Yeah, as said: don't use new, but rather use spring-dm to export BundleBClass 
as a service (you have to add an interface therefore) and import it into 
bundleAClass

this looks then something like:

bundleBspring

<bean id="a" class="XXX" />
<osgi:service interface="..." ref="a" />

bundleAspring

<bean id="b" class="YYY" >
<!-- via props or autowiring; as u like--> </> <osgi:reference interace="..." 
id="xyz" />

kind regards,
andreas

On Tue, Feb 15, 2011 at 06:08:59PM +0100, Marco Firrincieli wrote:
> I figured there must be a way to get a service from bundleB and IF that 
> service needs something (something he owns!) then I thought it could be 
> perfectly able to get it from its own spring context (that is 'wiring" it to 
> itself).
> 
> I don't need to actually get the autowired bean from bundleB. I need 
> bundleB to do something for me (bundleA). (in the example I need 
> BundleBClass.sayHello())
> 
> Gotta find a (quick) workaround to do this.
> 
> -----Original Message-----
> From: Andreas Pieber [mailto:[email protected]]
> Sent: martedì 15 febbraio 2011 17:42
> To: [email protected]; Marco Firrincieli
> Subject: Re: spring injected bean cannot be found
> 
> ah ok, this can't work this way... in bundlaA only the spring files in 
> bundleA count; if you define the autowiring things in 
> bundleA-spring-file it will work; BUT bundleA-spring-files have no 
> idea of bundleb-spring-files... I hope it is clear what I'm pointing 
> at... Typically you don't want to do a new XXX in bundleA but rather 
> import a service from bundleB
> 
> @thread: no it isn't you also have to remove the In-Reply-To: field in 
> the header; simply hitting reply and changing the subject does not 
> really create a new thread :)
> 
> kind regards,
> andreas
> 
> On Tue, Feb 15, 2011 at 05:41:33PM +0100, Marco Firrincieli wrote:
> > Here it comes:
> > 
> > (I’ve tried to simplify here... hope it works)
> > 
> > Here’s my karaf list command output (notice all I need is in an Active 
> > state).
> > 
> > [51] [Active] [] [] [75] my.legacy.something.just-a-jar
> > (1.0.0.SNAPSHOT) [105] [Active] [] [] [70] some.domain.beans
> > (1.0.0.SNAPSHOT) [142] [Active] [] [] [70] bundleB (1.0.0.SNAPSHOT) 
> > [142] [Active] [] [] [70] bundleA (1.0.0.SNAPSHOT)
> > 
> > at some point in bundleA i have:
> > 
> > package my.package.bundleA
> > 
> > import some.class.in.bundleB.BundleBClass;
> > 
> > public class MyClass {
> >     void doStuff() {
> >             new BundleBClass().sayHello();
> >     }
> > }
> > 
> > 
> > Whereas in bundleB
> > 
> > package some.class.in.bundleB;
> > 
> > public class BundleBClass {
> > 
> >     @Autowired
> >     private Sayer sayer;
> >     
> >     void sayHello() {
> >             this.sayer.say("hello");
> >     }
> > }
> > 
> > And of course bundleB exports its BundleBClass
> > 
> > 
> > I’ve got a wonderful nullpointer in sayHello method because "sayer" is 
> > null. The autowired doesn’t seem to work.
> > 
> > 
> > 
> > 
> > Ps: @Andreas, is this not a new thread?
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > From: [email protected] [mailto:[email protected]]
> > Sent: martedì 15 febbraio 2011 17:21
> > To: [email protected]; Marco Firrincieli
> > Subject: Re: spring injected bean cannot be found
> > 
> > Do you use blueprint for that or pure OSGi services ?
> > Could we have the spring file and the complete stack trace ?
> > 
> > Regards
> > JB
> > ________________________________________
> > From: Marco Firrincieli <[email protected]>
> > Date: Tue, 15 Feb 2011 17:20:41 +0100
> > To: [email protected]<[email protected]>
> > ReplyTo: [email protected]
> > Subject: spring injected bean cannot be found
> > 
> > One of my bundles (call it bundleA) instantiate a new Stuff() and this 
> > Stuff is another bundle (bundleB) (already up and running) and has a Spring 
> > autowired bean.
> > 
> > Result: nullpointerexception the (supposedly) injected bean.
> > 
> > Any idea? Should add something in bundleB’s manifest?
> > 
> > 
> > Can’t find much googling about this.
> > 
> > Thanks
> > 
> > -m

Reply via email to