You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Marco Firrincieli <Ma...@lbigroup.it> on 2011/02/15 13:04:19 UTC

newbie question: karaf always running

Seems like everytime i type "karaf" I start it AND run the console. Then "logout" actually shuts everything down.

How can I have it ALWAYS running and get in and out of the console?


Re: spring injected bean cannot be found

Posted by Guillaume Nodet <gn...@gmail.com>.
On Tue, Feb 15, 2011 at 17:19, Andreas Pieber <an...@gmail.com> wrote:
> Hey Marco,
>
> 1) please feel free to start a new thread for a new question :)
>
> 2) I'm sure that there has to be a notation in the log. I'm not exactly sure
> what you're doing here but I assume the following:
>
> bundleA
>
> imports InterfaceX;
>
> // this thing get autoinjected
> private InterfaceX x;
>
> bundleB
>
> public class ImplX implements InterfaceX {...
>
> The problem is that the maven-bundle-plugin only scans your imports, not your
> spring files --> he could not find ImplX (required by spring to instanciate the
> class) --> You have to add the import manually in your pom files.

Recent maven bundle plugins do actually scan the spring / blueprint files.
Though it can only detect direct references and namespaces won't work.

>
> kind regards,
> andreas
>
> On Tue, Feb 15, 2011 at 05:20:41PM +0100, Marco Firrincieli wrote:
>>    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
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: spring injected bean cannot be found

Posted by Andreas Pieber <an...@gmail.com>.
Hey Marco,

1) please feel free to start a new thread for a new question :)

2) I'm sure that there has to be a notation in the log. I'm not exactly sure
what you're doing here but I assume the following:

bundleA

imports InterfaceX;

// this thing get autoinjected
private InterfaceX x;

bundleB

public class ImplX implements InterfaceX {...

The problem is that the maven-bundle-plugin only scans your imports, not your
spring files --> he could not find ImplX (required by spring to instanciate the
class) --> You have to add the import manually in your pom files.

kind regards,
andreas

On Tue, Feb 15, 2011 at 05:20:41PM +0100, Marco Firrincieli wrote:
>    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

Re: spring injected bean cannot be found

Posted by Andreas Pieber <an...@gmail.com>.
Hey Marco,

Spring or blueprint both basically proxy the stuff done by
ServiceTracker (but making the injection much more beautiful IMHO).
Though if you have used neither spring nor blueprint by now for the
bundles I would recommend you to take a look at the Aries Blueprint
implementation which is coming with Karaf. I'm sure you'll like it :)

kind regards,
andreas

On Wed, Feb 16, 2011 at 9:47 PM, Marco Firrincieli
<Ma...@lbigroup.it> wrote:
> i had to use this ServiceTracker thing. it works but i did not really like it.
>
> i'm guessing my bundle should've been a spring-integration module of some kind (only really used spring for webapps).
>
> i'm wondering if it's worth giving a try or just leaving it as it is (servicetracker).
>
> ________________________________________
> From: Andreas Pieber [anpieber@gmail.com]
> Sent: 15 February 2011 19:13
> To: user@karaf.apache.org; Marco Firrincieli
> Subject: Re: spring injected bean cannot be found
>
> Either you create a spring-bundle or you simply user e.g. ServiceTracker to
> retrieve the service in the activator
>
> kind regards,
> andreas
>
> On Tue, Feb 15, 2011 at 07:17:22PM +0100, Marco Firrincieli wrote:
>> Alright.
>>
>> Just one more thing. My activator (inside bundleA) is not a spring project.
>>
>> so where do I put this <osgi:reference thingie?
>>
>>
>>
>> -----Original Message-----
>> From: Andreas Pieber [mailto:anpieber@gmail.com]
>> Sent: martedì 15 febbraio 2011 18:42
>> To: user@karaf.apache.org; Marco Firrincieli
>> Subject: Re: spring injected bean cannot be found
>>
>> On Tue, Feb 15, 2011 at 06:39:19PM +0100, Marco Firrincieli wrote:
>> > 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).
>>
>> there is already a feature for this available with karaf: spring-dm
>>
>> >
>> > That <osgi:service you put in comes from spring-osgi namespace (which I'll to add) right?
>>
>> ai, but best consult the spring-dm docs for the details. It's quite simple to export/import services using spring
>>
>> kind regards,
>> andreas
>>
>> >
>> >
>> > -----Original Message-----
>> > From: Andreas Pieber [mailto:anpieber@gmail.com]
>> > Sent: martedì 15 febbraio 2011 18:10
>> > To: user@karaf.apache.org; 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:anpieber@gmail.com]
>> > > Sent: martedì 15 febbraio 2011 17:42
>> > > To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
>> > > > Sent: martedì 15 febbraio 2011 17:21
>> > > > To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
>> > > > Date: Tue, 15 Feb 2011 17:20:41 +0100
>> > > > To: user@karaf.apache.org<us...@karaf.apache.org>
>> > > > ReplyTo: user@karaf.apache.org
>> > > > 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
>
>

RE: spring injected bean cannot be found

Posted by Marco Firrincieli <Ma...@lbigroup.it>.
i had to use this ServiceTracker thing. it works but i did not really like it.

i'm guessing my bundle should've been a spring-integration module of some kind (only really used spring for webapps).

i'm wondering if it's worth giving a try or just leaving it as it is (servicetracker).

________________________________________
From: Andreas Pieber [anpieber@gmail.com]
Sent: 15 February 2011 19:13
To: user@karaf.apache.org; Marco Firrincieli
Subject: Re: spring injected bean cannot be found

Either you create a spring-bundle or you simply user e.g. ServiceTracker to
retrieve the service in the activator

kind regards,
andreas

On Tue, Feb 15, 2011 at 07:17:22PM +0100, Marco Firrincieli wrote:
> Alright.
>
> Just one more thing. My activator (inside bundleA) is not a spring project.
>
> so where do I put this <osgi:reference thingie?
>
>
>
> -----Original Message-----
> From: Andreas Pieber [mailto:anpieber@gmail.com]
> Sent: martedì 15 febbraio 2011 18:42
> To: user@karaf.apache.org; Marco Firrincieli
> Subject: Re: spring injected bean cannot be found
>
> On Tue, Feb 15, 2011 at 06:39:19PM +0100, Marco Firrincieli wrote:
> > 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).
>
> there is already a feature for this available with karaf: spring-dm
>
> >
> > That <osgi:service you put in comes from spring-osgi namespace (which I'll to add) right?
>
> ai, but best consult the spring-dm docs for the details. It's quite simple to export/import services using spring
>
> kind regards,
> andreas
>
> >
> >
> > -----Original Message-----
> > From: Andreas Pieber [mailto:anpieber@gmail.com]
> > Sent: martedì 15 febbraio 2011 18:10
> > To: user@karaf.apache.org; 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:anpieber@gmail.com]
> > > Sent: martedì 15 febbraio 2011 17:42
> > > To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
> > > > Sent: martedì 15 febbraio 2011 17:21
> > > > To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
> > > > Date: Tue, 15 Feb 2011 17:20:41 +0100
> > > > To: user@karaf.apache.org<us...@karaf.apache.org>
> > > > ReplyTo: user@karaf.apache.org
> > > > 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


Re: spring injected bean cannot be found

Posted by Andreas Pieber <an...@gmail.com>.
Either you create a spring-bundle or you simply user e.g. ServiceTracker to
retrieve the service in the activator

kind regards,
andreas

On Tue, Feb 15, 2011 at 07:17:22PM +0100, Marco Firrincieli wrote:
> Alright.
> 
> Just one more thing. My activator (inside bundleA) is not a spring project.
> 
> so where do I put this <osgi:reference thingie?
> 
> 
> 
> -----Original Message-----
> From: Andreas Pieber [mailto:anpieber@gmail.com] 
> Sent: martedì 15 febbraio 2011 18:42
> To: user@karaf.apache.org; Marco Firrincieli
> Subject: Re: spring injected bean cannot be found
> 
> On Tue, Feb 15, 2011 at 06:39:19PM +0100, Marco Firrincieli wrote:
> > 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).
> 
> there is already a feature for this available with karaf: spring-dm
> 
> > 
> > That <osgi:service you put in comes from spring-osgi namespace (which I'll to add) right?
> 
> ai, but best consult the spring-dm docs for the details. It's quite simple to export/import services using spring
> 
> kind regards,
> andreas
> 
> > 
> > 
> > -----Original Message-----
> > From: Andreas Pieber [mailto:anpieber@gmail.com]
> > Sent: martedì 15 febbraio 2011 18:10
> > To: user@karaf.apache.org; 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:anpieber@gmail.com]
> > > Sent: martedì 15 febbraio 2011 17:42
> > > To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
> > > > Sent: martedì 15 febbraio 2011 17:21
> > > > To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
> > > > Date: Tue, 15 Feb 2011 17:20:41 +0100
> > > > To: user@karaf.apache.org<us...@karaf.apache.org>
> > > > ReplyTo: user@karaf.apache.org
> > > > 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

RE: spring injected bean cannot be found

Posted by Marco Firrincieli <Ma...@lbigroup.it>.
Alright.

Just one more thing. My activator (inside bundleA) is not a spring project.

so where do I put this <osgi:reference thingie?



-----Original Message-----
From: Andreas Pieber [mailto:anpieber@gmail.com] 
Sent: martedì 15 febbraio 2011 18:42
To: user@karaf.apache.org; Marco Firrincieli
Subject: Re: spring injected bean cannot be found

On Tue, Feb 15, 2011 at 06:39:19PM +0100, Marco Firrincieli wrote:
> 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).

there is already a feature for this available with karaf: spring-dm

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

ai, but best consult the spring-dm docs for the details. It's quite simple to export/import services using spring

kind regards,
andreas

> 
> 
> -----Original Message-----
> From: Andreas Pieber [mailto:anpieber@gmail.com]
> Sent: martedì 15 febbraio 2011 18:10
> To: user@karaf.apache.org; 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:anpieber@gmail.com]
> > Sent: martedì 15 febbraio 2011 17:42
> > To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
> > > Sent: martedì 15 febbraio 2011 17:21
> > > To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
> > > Date: Tue, 15 Feb 2011 17:20:41 +0100
> > > To: user@karaf.apache.org<us...@karaf.apache.org>
> > > ReplyTo: user@karaf.apache.org
> > > 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

Re: spring injected bean cannot be found

Posted by Andreas Pieber <an...@gmail.com>.
On Tue, Feb 15, 2011 at 06:39:19PM +0100, Marco Firrincieli wrote:
> 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).

there is already a feature for this available with karaf: spring-dm

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

ai, but best consult the spring-dm docs for the details. It's quite simple to
export/import services using spring

kind regards,
andreas

> 
> 
> -----Original Message-----
> From: Andreas Pieber [mailto:anpieber@gmail.com] 
> Sent: martedì 15 febbraio 2011 18:10
> To: user@karaf.apache.org; 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:anpieber@gmail.com]
> > Sent: martedì 15 febbraio 2011 17:42
> > To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
> > > Sent: martedì 15 febbraio 2011 17:21
> > > To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
> > > Date: Tue, 15 Feb 2011 17:20:41 +0100
> > > To: user@karaf.apache.org<us...@karaf.apache.org>
> > > ReplyTo: user@karaf.apache.org
> > > 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

RE: spring injected bean cannot be found

Posted by Marco Firrincieli <Ma...@lbigroup.it>.
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:anpieber@gmail.com] 
Sent: martedì 15 febbraio 2011 18:10
To: user@karaf.apache.org; 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:anpieber@gmail.com]
> Sent: martedì 15 febbraio 2011 17:42
> To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
> > Sent: martedì 15 febbraio 2011 17:21
> > To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
> > Date: Tue, 15 Feb 2011 17:20:41 +0100
> > To: user@karaf.apache.org<us...@karaf.apache.org>
> > ReplyTo: user@karaf.apache.org
> > 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

Re: spring injected bean cannot be found

Posted by Andreas Pieber <an...@gmail.com>.
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:anpieber@gmail.com] 
> Sent: martedì 15 febbraio 2011 17:42
> To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
> > Sent: martedì 15 febbraio 2011 17:21
> > To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
> > Date: Tue, 15 Feb 2011 17:20:41 +0100
> > To: user@karaf.apache.org<us...@karaf.apache.org>
> > ReplyTo: user@karaf.apache.org
> > 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

RE: spring injected bean cannot be found

Posted by Marco Firrincieli <Ma...@lbigroup.it>.
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:anpieber@gmail.com] 
Sent: martedì 15 febbraio 2011 17:42
To: user@karaf.apache.org; 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: jb@nanthrax.net [mailto:jb@nanthrax.net]
> Sent: martedì 15 febbraio 2011 17:21
> To: user@karaf.apache.org; 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 <Ma...@lbigroup.it>
> Date: Tue, 15 Feb 2011 17:20:41 +0100
> To: user@karaf.apache.org<us...@karaf.apache.org>
> ReplyTo: user@karaf.apache.org
> 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

Re: spring injected bean cannot be found

Posted by Andreas Pieber <an...@gmail.com>.
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: jb@nanthrax.net [mailto:jb@nanthrax.net] 
> Sent: martedì 15 febbraio 2011 17:21
> To: user@karaf.apache.org; 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 <Ma...@lbigroup.it> 
> Date: Tue, 15 Feb 2011 17:20:41 +0100
> To: user@karaf.apache.org<us...@karaf.apache.org>
> ReplyTo: user@karaf.apache.org 
> 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

RE: spring injected bean cannot be found

Posted by Marco Firrincieli <Ma...@lbigroup.it>.
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: jb@nanthrax.net [mailto:jb@nanthrax.net] 
Sent: martedì 15 febbraio 2011 17:21
To: user@karaf.apache.org; 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 <Ma...@lbigroup.it> 
Date: Tue, 15 Feb 2011 17:20:41 +0100
To: user@karaf.apache.org<us...@karaf.apache.org>
ReplyTo: user@karaf.apache.org 
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

Re: spring injected bean cannot be found

Posted by jb...@nanthrax.net.
Do you use blueprint for that or pure OSGi services ?
Could we have the spring file and the complete stack trace ?

Regards
JB
-----Original Message-----
From: Marco Firrincieli <Ma...@lbigroup.it>
Date: Tue, 15 Feb 2011 17:20:41 
To: user@karaf.apache.org<us...@karaf.apache.org>
Reply-To: user@karaf.apache.org
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

spring injected bean cannot be found

Posted by Marco Firrincieli <Ma...@lbigroup.it>.
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

RE: newbie question: karaf always running

Posted by Marco Firrincieli <Ma...@lbigroup.it>.
Thanks a lot

From: Andreas Pieber [mailto:anpieber@gmail.com]
Sent: martedì 15 febbraio 2011 13:10
To: user@karaf.apache.org; Marco Firrincieli
Subject: Re: newbie question: karaf always running


simply use the start script instead of karaf

kind regards
Andreas
On Feb 15, 2011 1:00 PM, "Marco Firrincieli" <Ma...@lbigroup.it>> wrote:
> Seems like everytime i type "karaf" I start it AND run the console. Then "logout" actually shuts everything down.
>
> How can I have it ALWAYS running and get in and out of the console?
>

Re: newbie question: karaf always running

Posted by Andreas Pieber <an...@gmail.com>.
simply use the start script instead of karaf

kind regards
Andreas
On Feb 15, 2011 1:00 PM, "Marco Firrincieli" <Ma...@lbigroup.it>
wrote:
> Seems like everytime i type "karaf" I start it AND run the console. Then
"logout" actually shuts everything down.
>
> How can I have it ALWAYS running and get in and out of the console?
>