You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Manuel Bernhardt <be...@gmail.com> on 2010/10/15 19:08:42 UTC

Karaf and Spring DM 2

Hello!

I'm a newcomer to Karaf, and would have a question regarding the
integration with Spring DM 2. I have an existing Karaf/Blueprint
project and would like to use spring DM as it offers advanced DI
features as well as a nice way of performing integration testing.

So I spent a good part of the day fighting (and understanding) how
Spring DM deals with custom namespaces, and was able to deploy a
bundle with Spring-DM 2.0 on Karaf. For doing so I created a custom
provision file and registered spring dm 2 as a feature.

Karaf 2.1 seems to come by default without Aries installed so I didn't
have any conflicts occurring there (or so I think at least). I mean I
didn't see Aries running when performing a osgi:list.

The issue I have now is that we use the Karaf shell extensions in
order to talk to our bundles via the console. This worked nicely with
a <command-bundle> declaration as long as I didn't inject dependencies
with spring (but wired them via hand). Now, spring not being the one
initializing the shell <action> classes, the dependencies are not
initialized.


My questions thus would be:

- how does the shell console look for it's extension points? Will it
only look in <command-bundle> definitions in a OSGI-INF/blueprint
path, or would it in theory be fine if the definition were in a spring
bundle-context definition file (with a custom namespace mapping). My
aim would be to have spring initialize the instance (and wire its
dependencies) but still have the shell know about it / how to talk to
it.

- it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
online, whilst that would be handy to have

- does what I am trying to do make any sense at all? (I'm rather new
to the latest OSGi spec, and am not sure what the usual practices are)

Thanks!

Manuel

Re: Karaf and Spring DM 2

Posted by Manuel Bernhardt <be...@gmail.com>.
Hi,

> Which class does the uimInfoShell bean extends ?

It was implementing org.apache.felix.service.command.Function, and I
had a wrong library in the classpath.

Now the shell class implements org.osgi.service.command.Function and
is directly declared as service, like so:

        <bp:service id="fileShell" ref="uimFileShell"
interface="org.osgi.service.command.Function">
            <bp:service-properties>
                <bp:entry key="osgi.command.function" value="file"/>
                <bp:entry key="osgi.command.scope" value="uim"/>
            </bp:service-properties>
        </bp:service>

and this works nicely.


Also, the bundles work now with Spring DM 2 on Karaf.

The only thing that is a bit fishy is that upon installing the
spring-dm-2 feature (feature descriptor at the end of the mail), I get
a set of ugly stacktraces. I also get these upon re-starting Karaf.

I'm pasting a shortened version of it here:

karaf@root> features:install spring-dm-2
Refreshing bundles org.springframework.aop (52),
org.springframework.context (53), org.springframework.beans (51)
Exception in thread "SpringOsgiExtenderThread-2"
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'featureUrlHandlerRef': Invocation of init
method failed; nested exception is java.lang.IllegalArgumentException:
invalid filter: url.handler.protocol=feature
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
        ...
Caused by: java.lang.IllegalArgumentException: invalid filter:
url.handler.protocol=feature
        at org.springframework.osgi.util.OsgiFilterUtils.unifyFilter(OsgiFilterUtils.java:138)
        ...
        ... 19 more
Exception in thread "SpringOsgiExtenderThread-5"
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'blueprintUrlHandlerRef': Invocation of init
method failed; nested exception is java.lang.IllegalArgumentException:
invalid filter: url.handler.protocol=blueprint
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
        ...
        at java.lang.Thread.run(Thread.java:637)
Caused by: java.lang.IllegalArgumentException: invalid filter:
url.handler.protocol=blueprint
        at org.springframework.osgi.util.OsgiFilterUtils.unifyFilter(OsgiFilterUtils.java:138)
        ...
        ... 17 more
karaf@root> Exception in thread "SpringOsgiExtenderThread-16"
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'springUrlHandlerRef': Invocation of init
method failed; nested exception is java.lang.IllegalArgumentException:
invalid filter: url.handler.protocol=spring
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
        ...
        at java.lang.Thread.run(Thread.java:637)
Caused by: java.lang.IllegalArgumentException: invalid filter:
url.handler.protocol=spring
        at org.springframework.osgi.util.OsgiFilterUtils.unifyFilter(OsgiFilterUtils.java:138)
        ...
        ... 17 more


what's more interesting though is the log (unshortened version at
http://pastie.org/pastes/1234859/text):


09:32:10,768 | INFO  | l Console Thread | BlueprintContainerCreator
    | upport.BlueprintContainerCreator   56 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Discovered
configurations {bundle://74.0:0/OSGI-INF/blueprint/blueprint-cm.xml,
bundle://74.0:0/OSGI-INF/blueprint/blueprint-ext.xml} in bundle
[Apache Aries Blueprint Bundle
(org.apache.aries.blueprint;blueprint.graceperiod:=false)]
09:32:10,774 | INFO  | l Console Thread | LifecycleManager
    | ernal.activator.LifecycleManager  189 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Bundle Apache Aries
Blueprint Bundle is not type compatible with extender
spring-osgi-extender; ignoring bundle...
09:32:10,775 | WARN  | ExtenderThread-8 | CustomListenerAdapterUtils
    | apter.CustomListenerAdapterUtils  224 | 155 -
org.springframework.osgi.core - 2.0.0.M1 | Custom method [public void
org.apache.karaf.management.MBeanRegistrer.registerMBeanServer(javax.management.MBeanServer)
throws javax.management.JMException] threw exception when passing
service [$Proxy39@47710808]
javax.management.InstanceAlreadyExistsException:
org.apache.karaf:type=features,name=root
        at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)[:1.6.0_20]
        <snip />

09:32:10,773 | INFO  | xtenderThread-13 | DefaultListableBeanFactory
    | pport.DefaultListableBeanFactory  549 | 51 -
org.springframework.beans - 3.0.3.RELEASE | Pre-instantiating
singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6a0bcf47:
defining beans [adminService,mbeanServer,mbeanImpl,mbeanRegister,blueprintBundle,blueprintBundleContext,blueprintContainer,blueprintConverter];
root of factory hierarchy
09:32:10,777 | INFO  | ExtenderThread-4 | OsgiServiceFactoryBean
    | r.support.OsgiServiceFactoryBean  369 | 155 -
org.springframework.osgi.core - 2.0.0.M1 | Publishing service under
classes [{org.osgi.service.command.Function}]
09:32:10,791 | INFO  | l Console Thread | BlueprintContainerCreator
    | upport.BlueprintContainerCreator   56 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Discovered
configurations {bundle://158.0:0/OSGI-INF/blueprint/spring-deployer.xml}
in bundle [Apache Karaf :: Spring Deployer
(org.apache.karaf.deployer.spring;blueprint.graceperiod:=false)]
09:32:10,776 | INFO  | ExtenderThread-3 | UIMRegistry
    | eu.europeana.uim.UIMRegistry       40 |  -  -  | Added
storage:MemoryStorageEngine
09:32:10,795 | INFO  | ExtenderThread-8 |
ueprintContainerServicePublisher | ueprintContainerServicePublisher
97 | 155 - org.springframework.osgi.core - 2.0.0.M1 | Publishing
BlueprintContainer as OSGi service with properties
{Bundle-SymbolicName=org.apache.karaf.features.management,
Bundle-Version=2.1.0, osgi.blueprint.container.version=2.1.0,
osgi.blueprint.container.symbolicname=org.apache.karaf.features.management}
09:32:10,793 | INFO  | ExtenderThread-4 |
OsgiBundleXmlApplicationContext  | ractOsgiBundleApplicationContext
328 | 53 - org.springframework.context - 3.0.3.RELEASE | Publishing
application context as OSGi service with properties
{org.springframework.context.service.name=eu.europeana.uim-import-file,
Bundle-SymbolicName=eu.europeana.uim-import-file,
Bundle-Version=1.0.0.SNAPSHOT}
09:32:10,793 | INFO  | xtenderThread-16 |
OsgiBundleXmlApplicationContext  | pport.AbstractApplicationContext
456 | 53 - org.springframework.context - 3.0.3.RELEASE | Refreshing
OsgiBundleXmlApplicationContext(bundle=org.apache.karaf.deployer.spring,
config=bundle://158.0:0/OSGI-INF/blueprint/spring-deployer.xml):
startup date [Wed Oct 20 09:32:10 CEST 2010]; root of context
hierarchy
09:32:10,802 | INFO  | xtenderThread-16 |
OsgiBundleXmlApplicationContext  | ractOsgiBundleApplicationContext
383 | 53 - org.springframework.context - 3.0.3.RELEASE | Application
Context service already unpublished
09:32:10,804 | INFO  | ExtenderThread-4 | ContextLoaderListener
    | BundleApplicationContextListener   47 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Application context
successfully refreshed
(OsgiBundleXmlApplicationContext(bundle=eu.europeana.uim-import-file,
config=osgibundle:/META-INF/spring/*.xml))
09:32:10,806 | INFO  | xtenderThread-16 | XmlBeanDefinitionReader
    | tory.xml.XmlBeanDefinitionReader  315 | 51 -
org.springframework.beans - 3.0.3.RELEASE | Loading XML bean
definitions from OSGi
resource[bundle://158.0:0/OSGI-INF/blueprint/spring-deployer.xml|bnd.id=158|bnd.sym=org.apache.karaf.deployer.spring]
09:32:10,813 | INFO  | ExtenderThread-8 |
OsgiBundleXmlApplicationContext  | ractOsgiBundleApplicationContext
328 | 53 - org.springframework.context - 3.0.3.RELEASE | Publishing
application context as OSGi service with properties
{org.springframework.context.service.name=org.apache.karaf.features.management,
Bundle-SymbolicName=org.apache.karaf.features.management,
Bundle-Version=2.1.0}
09:32:10,820 | WARN  | xtenderThread-13 | CustomListenerAdapterUtils
    | apter.CustomListenerAdapterUtils  224 | 155 -
org.springframework.osgi.core - 2.0.0.M1 | Custom method [public void
org.apache.karaf.management.MBeanRegistrer.registerMBeanServer(javax.management.MBeanServer)
throws javax.management.JMException] threw exception when passing
service [$Proxy44@1ddeda00]
javax.management.InstanceAlreadyExistsException:
org.apache.karaf:type=admin,name=root
        at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)[:1.6.0_20]
        <snip - same stacktrace as before />

09:32:10,832 | INFO  | ExtenderThread-3 | OsgiServiceFactoryBean
    | r.support.OsgiServiceFactoryBean  369 | 155 -
org.springframework.osgi.core - 2.0.0.M1 | Publishing service under
classes [{org.osgi.service.command.Function}]
09:32:10,826 | INFO  | xtenderThread-16 | DefaultListableBeanFactory
    | pport.DefaultListableBeanFactory  549 | 51 -
org.springframework.beans - 3.0.3.RELEASE | Pre-instantiating
singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@42eab1f2:
defining beans [springUrlHandler,springDeploymentListener,springUrlHandlerRef,.org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0,blueprintBundle,blueprintBundleContext,blueprintContainer,blueprintConverter];
root of factory hierarchy
09:32:10,836 | INFO  | xtenderThread-16 | OsgiServiceFactoryBean
    | r.support.OsgiServiceFactoryBean  369 | 155 -
org.springframework.osgi.core - 2.0.0.M1 | Publishing service under
classes [{org.osgi.service.url.URLStreamHandlerService}]
09:32:10,830 | INFO  | ExtenderThread-8 | BlueprintLoaderListener
    | BundleApplicationContextListener   47 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Application context
successfully refreshed
(OsgiBundleXmlApplicationContext(bundle=org.apache.karaf.features.management,
config=bundle://10.0:0/OSGI-INF/blueprint/features-management.xml))
09:32:10,837 | INFO  | xtenderThread-13 |
ueprintContainerServicePublisher | ueprintContainerServicePublisher
97 | 155 - org.springframework.osgi.core - 2.0.0.M1 | Publishing
BlueprintContainer as OSGi service with properties
{Bundle-SymbolicName=org.apache.karaf.admin.management,
Bundle-Version=2.1.0, osgi.blueprint.container.version=2.1.0,
osgi.blueprint.container.symbolicname=org.apache.karaf.admin.management}
09:32:10,838 | INFO  | xtenderThread-13 |
OsgiBundleXmlApplicationContext  | ractOsgiBundleApplicationContext
328 | 53 - org.springframework.context - 3.0.3.RELEASE | Publishing
application context as OSGi service with properties
{org.springframework.context.service.name=org.apache.karaf.admin.management,
Bundle-SymbolicName=org.apache.karaf.admin.management,
Bundle-Version=2.1.0}
09:32:10,837 | INFO  | ExtenderThread-3 |
OsgiBundleXmlApplicationContext  | ractOsgiBundleApplicationContext
328 | 53 - org.springframework.context - 3.0.3.RELEASE | Publishing
application context as OSGi service with properties
{org.springframework.context.service.name=eu.europeana.uim-api,
Bundle-SymbolicName=eu.europeana.uim-api,
Bundle-Version=1.0.0.SNAPSHOT}
09:32:10,838 | INFO  | xtenderThread-16 | DefaultListableBeanFactory
    | ort.DefaultSingletonBeanRegistry  422 | 51 -
org.springframework.beans - 3.0.3.RELEASE | Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@42eab1f2:
defining beans [springUrlHandler,springDeploymentListener,springUrlHandlerRef,.org.springframework.osgi.service.exporter.support.OsgiServiceFactoryBean#0,blueprintBundle,blueprintBundleContext,blueprintContainer,blueprintConverter];
root of factory hierarchy
09:32:10,839 | INFO  | xtenderThread-16 | OsgiServiceFactoryBean
    | r.support.OsgiServiceFactoryBean  452 | 155 -
org.springframework.osgi.core - 2.0.0.M1 | Unregistered service
[ServiceRegistrationWrapper for
org.apache.felix.framework.ServiceRegistrationImpl@4dffa9d]
09:32:10,839 | ERROR | xtenderThread-16 | BlueprintLoaderListener
    | BundleApplicationContextListener   52 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Application context
refresh failed (OsgiBundleXmlApplicationContext(bundle=org.apache.karaf.deployer.spring,
config=bundle://158.0:0/OSGI-INF/blueprint/spring-deployer.xml))
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'springUrlHandlerRef': Invocation of init
method failed; nested exception is java.lang.IllegalArgumentException:
invalid filter: url.handler.protocol=spring
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)[51:org.springframework.beans:3.0.3.RELEASE]
<snip />

09:32:10,840 | INFO  | xtenderThread-13 | BlueprintLoaderListener
    | BundleApplicationContextListener   47 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Application context
successfully refreshed
(OsgiBundleXmlApplicationContext(bundle=org.apache.karaf.admin.management,
config=bundle://28.0:0/OSGI-INF/blueprint/admin-management.xml))
09:32:10,845 | INFO  | ExtenderThread-3 | ContextLoaderListener
    | BundleApplicationContextListener   47 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Application context
successfully refreshed
(OsgiBundleXmlApplicationContext(bundle=eu.europeana.uim-api,
config=osgibundle:/META-INF/spring/*.xml))



I'm not really sure what happens here, but I think there might be two things:

- Spring having trouble with various keys:
  - java.lang.IllegalArgumentException: invalid filter:
url.handler.protocol=feature
  - java.lang.IllegalArgumentException: invalid filter:
url.handler.protocol=blueprint
  - java.lang.IllegalArgumentException: invalid filter:
url.handler.protocol=spring

- Something (not sure what) already existing:
        javax.management.InstanceAlreadyExistsException:
org.apache.karaf:type=features,name=root
        at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)[:1.6.0_20]
        <snip />

What's interesting too is what Spring says about Aries:

09:32:10,774 | INFO  | l Console Thread | LifecycleManager
    | ernal.activator.LifecycleManager  189 | 156 -
org.springframework.osgi.extender - 2.0.0.M1 | Bundle Apache Aries
Blueprint Bundle is not type compatible with extender
spring-osgi-extender; ignoring bundle...


Here is the feature descriptor I use, I can also provide the maven
configuration required to get all these dependencies (it's somewhat
tricky to find the right repositories):

<?xml version="1.0" encoding="UTF-8"?>
<features name="spring-features">
    <feature name="spring-dm-2" version="2.0.0.M1">
        <feature version="3.0.3.RELEASE">spring</feature>
        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/2.1_3_6</bundle>
        <bundle>mvn:org.springframework.osgi/spring-osgi-io/2.0.0.M1</bundle>
        <bundle>mvn:org.springframework.osgi/spring-osgi-core/2.0.0.M1</bundle>
        <bundle>mvn:org.springframework.osgi/spring-osgi-extender/2.0.0.M1</bundle>
        <bundle>mvn:org.springframework.osgi/spring-osgi-annotation/2.0.0.M1</bundle>
        <bundle>mvn:org.apache.karaf.deployer/org.apache.karaf.deployer.spring/2.1.0</bundle>
    </feature>
</features>


I'd be interested in looking more into this, i.e. to see what is the
cause of the exceptions thrown above.

Thanks,

Manuel




On Mon, Oct 18, 2010 at 3:48 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> Which class does the uimInfoShell bean extends ?
> There's something weird in the stack trace, as if the bean implements the
> Function interface, i don't think the
>  org.apache.felix.gogo.runtime.shell.Reflective should be involved.
> Can you check the wiring with the 'package:imports' command and make sure
> the org.apache.felix.service.command is correctly imported from the
> karaf.console bundle ?
>
> On Mon, Oct 18, 2010 at 15:38, Manuel Bernhardt <be...@gmail.com>
> wrote:
>>
>> Hi,
>>
>> On Mon, Oct 18, 2010 at 2:32 PM, Guillaume Nodet <gn...@gmail.com> wrote:
>> > Note that @Autowired could be achieved by an explicit wiring in
>> > blueprint if
>> > the bean has setters.
>> > Let me know if you need more help, that's an are i'm interested in going
>> > to
>> > the bottom, as I'm still unclear what works and what does not.
>>
>> Thanks, actually I would need more help with the shell command service:
>>
>> Spring DM gets installed as a feature -- with a load of stacktraces,
>> but in the end it seems to run and deploy things nicely. I guess I'll
>> give you the stacktraces later on, when I'm sure it actually works as
>> expected (right now the shell is the only means I have to do so).
>>
>> I now declared a blueprint service in the spring-dm bundle-context:
>>
>>        <bp:service id="infoShell" ref="uimInfoShell"
>> interface="org.apache.felix.service.command.Function">
>>            <bp:service-properties>
>>                <bp:entry key="osgi.command.function" value="info"/>
>>                <bp:entry key="osgi.command.scope" value="uim"/>
>>            </bp:service-properties>
>>        </bp:service>
>>
>> together with a "uimInfoShell" bean which points to the implementation.
>>
>> Upon running "uim:info" in the console, I get
>>
>> 15:23:36,070 | INFO  | l Console Thread | Console
>>    | araf.shell.console.jline.Console  187 | 17 -
>> org.apache.karaf.shell.console - 2.1.0 | Exception caught while
>> executing command
>> java.lang.IllegalArgumentException: Cannot coerce info[] to any of []
>>        at
>> org.apache.felix.gogo.runtime.shell.Reflective.method(Reflective.java:174)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:54)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.karaf.shell.console.jline.Console.run(Console.java:169)[17:org.apache.karaf.shell.console:2.1.0]
>>        at java.lang.Thread.run(Thread.java:637)[:1.6.0_20]
>>
>>
>> I found a similar trace at
>> http://felix.apache.org/site/rfc-147-overview.html but I'm not really
>> sure what it means.
>>
>> The uimInfo execute() method only does a few System.out's and returns
>> null - is there anything else I need to do?
>>
>> Thanks,
>>
>> Manuel
>>
>>
>>
>>
>>
>> 15:23:36,070 | INFO  | l Console Thread | Console
>>    | araf.shell.console.jline.Console  187 | 17 -
>> org.apache.karaf.shell.console - 2.1.0 | Exception caught while
>> executing command
>> java.lang.IllegalArgumentException: Cannot coerce info[] to any of []
>>        at
>> org.apache.felix.gogo.runtime.shell.Reflective.method(Reflective.java:174)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:54)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)[17:org.apache.karaf.shell.console:2.1.0]
>>        at
>> org.apache.karaf.shell.console.jline.Console.run(Console.java:169)[17:org.apache.karaf.shell.console:2.1.0]
>>        at java.lang.Thread.run(Thread.java:637)[:1.6.0_20]
>>
>> On Mon, Oct 18, 2010 at 2:32 PM, Guillaume Nodet <gn...@gmail.com> wrote:
>> > Note that @Autowired could be achieved by an explicit wiring in
>> > blueprint if
>> > the bean has setters.
>> > Let me know if you need more help, that's an are i'm interested in going
>> > to
>> > the bottom, as I'm still unclear what works and what does not.
>> >
>> > On Fri, Oct 15, 2010 at 22:24, Manuel Bernhardt
>> > <be...@gmail.com>
>> > wrote:
>> >>
>> >> Salut!
>> >>
>> >> On Fri, Oct 15, 2010 at 7:19 PM, Guillaume Nodet <gn...@gmail.com>
>> >> wrote:
>> >> > Yeah, that has changed in 2.1 where Karaf does not display the
>> >> > pre-installed
>> >> > bundle anymore.
>> >> > Try 'la' in the console to see all the bundles.  The Aries Blueprint
>> >> > impl is
>> >> > used by a lot of bundles in karaf.
>> >>
>> >> Indeed. Well then I'll probably have some more surprises with the two
>> >> Blueprint implementations running side-by-side
>> >>
>> >> >> The issue I have now is that we use the Karaf shell extensions in
>> >> >> order to talk to our bundles via the console. This worked nicely
>> >> >> with
>> >> >> a <command-bundle> declaration as long as I didn't inject
>> >> >> dependencies
>> >> >> with spring (but wired them via hand). Now, spring not being the one
>> >> >> initializing the shell <action> classes, the dependencies are not
>> >> >> initialized.
>> >> >
>> >> > Not sure to exactly follow what you did with spring.
>> >>
>> >> Mainly the shell extension (extending OsgiCommandSupport) has a member
>> >> that is injected via @AutoWired. The type is declared in the spring
>> >> bundle context.
>> >>
>> >> >> - how does the shell console look for it's extension points? Will it
>> >> >> only look in <command-bundle> definitions in a OSGI-INF/blueprint
>> >> >> path, or would it in theory be fine if the definition were in a
>> >> >> spring
>> >> >> bundle-context definition file (with a custom namespace mapping). My
>> >> >> aim would be to have spring initialize the instance (and wire its
>> >> >> dependencies) but still have the shell know about it / how to talk
>> >> >> to
>> >> >> it.
>> >> >
>> >> > The console looks for services in the registry.  The custom blueprint
>> >> > namespace is just a simple way to expose the service.
>> >> > To add a command to the console if you're no using blueprint,
>> >> > register a
>> >> > service implementing the org.apache.felix.service.command.Function
>> >> > interface
>> >> > and with the osgi.command.function and osgi.command.scope service
>> >> > properties.   Try "ls -a 14' for example in the karaf console to see
>> >> > a
>> >> > bunch
>> >> > of those methods.   The helper classes are located in the
>> >> > o.a.karaf.shell.console bundle.
>> >>
>> >> Great, thanks!
>> >>
>> >> >> - it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
>> >> >> online, whilst that would be handy to have
>> >> >
>> >> > Wanna raise a JIRA, that should be fixed.
>> >> > You can find it at
>> >> >
>> >> >
>> >> > http://svn.apache.org/repos/asf/karaf/tags/karaf-2.1.0/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell.xsd
>> >> > in the mean time.
>> >>
>> >> Will file a ticket
>> >>
>> >> >> - does what I am trying to do make any sense at all? (I'm rather new
>> >> >> to the latest OSGi spec, and am not sure what the usual practices
>> >> >> are)
>> >> >
>> >> > What are you trying to do? Do you only need to register a set of
>> >> > commands
>> >> > using spring-dm ?  Do you really need to use the blueprint
>> >> > implemnttion
>> >> > from
>> >> > spring?
>> >>
>> >> Actually I don't care so much for the blueprint implementation. What I
>> >> am after is spring's dependency injection toolset and the integration
>> >> test facility
>> >>
>> >> (http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/testing.html#testing:integration).
>> >> If I understood things right, I do need spring dm to be running on the
>> >> platform in order to get those, or not?
>> >>
>> >> Thanks,
>> >>
>> >> Manuel
>> >
>> >
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> > ------------------------
>> > Blog: http://gnodet.blogspot.com/
>> > ------------------------
>> > Open Source SOA
>> > http://fusesource.com
>> >
>> >
>> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>
>
>

Re: Karaf and Spring DM 2

Posted by Guillaume Nodet <gn...@gmail.com>.
Which class does the uimInfoShell bean extends ?
There's something weird in the stack trace, as if the bean implements the
Function interface, i don't think the
org.apache.felix.gogo.runtime.shell.Reflective
should be involved.
Can you check the wiring with the 'package:imports' command and make sure
the org.apache.felix.service.command is correctly imported from the
karaf.console bundle ?

On Mon, Oct 18, 2010 at 15:38, Manuel Bernhardt
<be...@gmail.com>wrote:

> Hi,
>
> On Mon, Oct 18, 2010 at 2:32 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> > Note that @Autowired could be achieved by an explicit wiring in blueprint
> if
> > the bean has setters.
> > Let me know if you need more help, that's an are i'm interested in going
> to
> > the bottom, as I'm still unclear what works and what does not.
>
> Thanks, actually I would need more help with the shell command service:
>
> Spring DM gets installed as a feature -- with a load of stacktraces,
> but in the end it seems to run and deploy things nicely. I guess I'll
> give you the stacktraces later on, when I'm sure it actually works as
> expected (right now the shell is the only means I have to do so).
>
> I now declared a blueprint service in the spring-dm bundle-context:
>
>        <bp:service id="infoShell" ref="uimInfoShell"
> interface="org.apache.felix.service.command.Function">
>            <bp:service-properties>
>                <bp:entry key="osgi.command.function" value="info"/>
>                <bp:entry key="osgi.command.scope" value="uim"/>
>            </bp:service-properties>
>        </bp:service>
>
> together with a "uimInfoShell" bean which points to the implementation.
>
> Upon running "uim:info" in the console, I get
>
> 15:23:36,070 | INFO  | l Console Thread | Console
>    | araf.shell.console.jline.Console  187 | 17 -
> org.apache.karaf.shell.console - 2.1.0 | Exception caught while
> executing command
> java.lang.IllegalArgumentException: Cannot coerce info[] to any of []
>        at
> org.apache.felix.gogo.runtime.shell.Reflective.method(Reflective.java:174)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:54)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.karaf.shell.console.jline.Console.run(Console.java:169)[17:org.apache.karaf.shell.console:2.1.0]
>        at java.lang.Thread.run(Thread.java:637)[:1.6.0_20]
>
>
> I found a similar trace at
> http://felix.apache.org/site/rfc-147-overview.html but I'm not really
> sure what it means.
>
> The uimInfo execute() method only does a few System.out's and returns
> null - is there anything else I need to do?
>
> Thanks,
>
> Manuel
>
>
>
>
>
> 15:23:36,070 | INFO  | l Console Thread | Console
>    | araf.shell.console.jline.Console  187 | 17 -
> org.apache.karaf.shell.console - 2.1.0 | Exception caught while
> executing command
> java.lang.IllegalArgumentException: Cannot coerce info[] to any of []
>        at
> org.apache.felix.gogo.runtime.shell.Reflective.method(Reflective.java:174)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:54)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)[17:org.apache.karaf.shell.console:2.1.0]
>        at
> org.apache.karaf.shell.console.jline.Console.run(Console.java:169)[17:org.apache.karaf.shell.console:2.1.0]
>        at java.lang.Thread.run(Thread.java:637)[:1.6.0_20]
>
> On Mon, Oct 18, 2010 at 2:32 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> > Note that @Autowired could be achieved by an explicit wiring in blueprint
> if
> > the bean has setters.
> > Let me know if you need more help, that's an are i'm interested in going
> to
> > the bottom, as I'm still unclear what works and what does not.
> >
> > On Fri, Oct 15, 2010 at 22:24, Manuel Bernhardt <
> bernhardt.manuel@gmail.com>
> > wrote:
> >>
> >> Salut!
> >>
> >> On Fri, Oct 15, 2010 at 7:19 PM, Guillaume Nodet <gn...@gmail.com>
> wrote:
> >> > Yeah, that has changed in 2.1 where Karaf does not display the
> >> > pre-installed
> >> > bundle anymore.
> >> > Try 'la' in the console to see all the bundles.  The Aries Blueprint
> >> > impl is
> >> > used by a lot of bundles in karaf.
> >>
> >> Indeed. Well then I'll probably have some more surprises with the two
> >> Blueprint implementations running side-by-side
> >>
> >> >> The issue I have now is that we use the Karaf shell extensions in
> >> >> order to talk to our bundles via the console. This worked nicely with
> >> >> a <command-bundle> declaration as long as I didn't inject
> dependencies
> >> >> with spring (but wired them via hand). Now, spring not being the one
> >> >> initializing the shell <action> classes, the dependencies are not
> >> >> initialized.
> >> >
> >> > Not sure to exactly follow what you did with spring.
> >>
> >> Mainly the shell extension (extending OsgiCommandSupport) has a member
> >> that is injected via @AutoWired. The type is declared in the spring
> >> bundle context.
> >>
> >> >> - how does the shell console look for it's extension points? Will it
> >> >> only look in <command-bundle> definitions in a OSGI-INF/blueprint
> >> >> path, or would it in theory be fine if the definition were in a
> spring
> >> >> bundle-context definition file (with a custom namespace mapping). My
> >> >> aim would be to have spring initialize the instance (and wire its
> >> >> dependencies) but still have the shell know about it / how to talk to
> >> >> it.
> >> >
> >> > The console looks for services in the registry.  The custom blueprint
> >> > namespace is just a simple way to expose the service.
> >> > To add a command to the console if you're no using blueprint, register
> a
> >> > service implementing the org.apache.felix.service.command.Function
> >> > interface
> >> > and with the osgi.command.function and osgi.command.scope service
> >> > properties.   Try "ls -a 14' for example in the karaf console to see a
> >> > bunch
> >> > of those methods.   The helper classes are located in the
> >> > o.a.karaf.shell.console bundle.
> >>
> >> Great, thanks!
> >>
> >> >> - it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
> >> >> online, whilst that would be handy to have
> >> >
> >> > Wanna raise a JIRA, that should be fixed.
> >> > You can find it at
> >> >
> >> >
> http://svn.apache.org/repos/asf/karaf/tags/karaf-2.1.0/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell.xsd
> >> > in the mean time.
> >>
> >> Will file a ticket
> >>
> >> >> - does what I am trying to do make any sense at all? (I'm rather new
> >> >> to the latest OSGi spec, and am not sure what the usual practices
> are)
> >> >
> >> > What are you trying to do? Do you only need to register a set of
> >> > commands
> >> > using spring-dm ?  Do you really need to use the blueprint
> implemnttion
> >> > from
> >> > spring?
> >>
> >> Actually I don't care so much for the blueprint implementation. What I
> >> am after is spring's dependency injection toolset and the integration
> >> test facility
> >> (
> http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/testing.html#testing:integration
> ).
> >> If I understood things right, I do need spring dm to be running on the
> >> platform in order to get those, or not?
> >>
> >> Thanks,
> >>
> >> Manuel
> >
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> > ------------------------
> > Open Source SOA
> > http://fusesource.com
> >
> >
> >
>



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

Re: Karaf and Spring DM 2

Posted by Manuel Bernhardt <be...@gmail.com>.
Hi,

On Mon, Oct 18, 2010 at 2:32 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> Note that @Autowired could be achieved by an explicit wiring in blueprint if
> the bean has setters.
> Let me know if you need more help, that's an are i'm interested in going to
> the bottom, as I'm still unclear what works and what does not.

Thanks, actually I would need more help with the shell command service:

Spring DM gets installed as a feature -- with a load of stacktraces,
but in the end it seems to run and deploy things nicely. I guess I'll
give you the stacktraces later on, when I'm sure it actually works as
expected (right now the shell is the only means I have to do so).

I now declared a blueprint service in the spring-dm bundle-context:

        <bp:service id="infoShell" ref="uimInfoShell"
interface="org.apache.felix.service.command.Function">
            <bp:service-properties>
                <bp:entry key="osgi.command.function" value="info"/>
                <bp:entry key="osgi.command.scope" value="uim"/>
            </bp:service-properties>
        </bp:service>

together with a "uimInfoShell" bean which points to the implementation.

Upon running "uim:info" in the console, I get

15:23:36,070 | INFO  | l Console Thread | Console
    | araf.shell.console.jline.Console  187 | 17 -
org.apache.karaf.shell.console - 2.1.0 | Exception caught while
executing command
java.lang.IllegalArgumentException: Cannot coerce info[] to any of []
        at org.apache.felix.gogo.runtime.shell.Reflective.method(Reflective.java:174)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:54)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.karaf.shell.console.jline.Console.run(Console.java:169)[17:org.apache.karaf.shell.console:2.1.0]
        at java.lang.Thread.run(Thread.java:637)[:1.6.0_20]


I found a similar trace at
http://felix.apache.org/site/rfc-147-overview.html but I'm not really
sure what it means.

The uimInfo execute() method only does a few System.out's and returns
null - is there anything else I need to do?

Thanks,

Manuel





15:23:36,070 | INFO  | l Console Thread | Console
    | araf.shell.console.jline.Console  187 | 17 -
org.apache.karaf.shell.console - 2.1.0 | Exception caught while
executing command
java.lang.IllegalArgumentException: Cannot coerce info[] to any of []
        at org.apache.felix.gogo.runtime.shell.Reflective.method(Reflective.java:174)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:54)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)[17:org.apache.karaf.shell.console:2.1.0]
        at org.apache.karaf.shell.console.jline.Console.run(Console.java:169)[17:org.apache.karaf.shell.console:2.1.0]
        at java.lang.Thread.run(Thread.java:637)[:1.6.0_20]

On Mon, Oct 18, 2010 at 2:32 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> Note that @Autowired could be achieved by an explicit wiring in blueprint if
> the bean has setters.
> Let me know if you need more help, that's an are i'm interested in going to
> the bottom, as I'm still unclear what works and what does not.
>
> On Fri, Oct 15, 2010 at 22:24, Manuel Bernhardt <be...@gmail.com>
> wrote:
>>
>> Salut!
>>
>> On Fri, Oct 15, 2010 at 7:19 PM, Guillaume Nodet <gn...@gmail.com> wrote:
>> > Yeah, that has changed in 2.1 where Karaf does not display the
>> > pre-installed
>> > bundle anymore.
>> > Try 'la' in the console to see all the bundles.  The Aries Blueprint
>> > impl is
>> > used by a lot of bundles in karaf.
>>
>> Indeed. Well then I'll probably have some more surprises with the two
>> Blueprint implementations running side-by-side
>>
>> >> The issue I have now is that we use the Karaf shell extensions in
>> >> order to talk to our bundles via the console. This worked nicely with
>> >> a <command-bundle> declaration as long as I didn't inject dependencies
>> >> with spring (but wired them via hand). Now, spring not being the one
>> >> initializing the shell <action> classes, the dependencies are not
>> >> initialized.
>> >
>> > Not sure to exactly follow what you did with spring.
>>
>> Mainly the shell extension (extending OsgiCommandSupport) has a member
>> that is injected via @AutoWired. The type is declared in the spring
>> bundle context.
>>
>> >> - how does the shell console look for it's extension points? Will it
>> >> only look in <command-bundle> definitions in a OSGI-INF/blueprint
>> >> path, or would it in theory be fine if the definition were in a spring
>> >> bundle-context definition file (with a custom namespace mapping). My
>> >> aim would be to have spring initialize the instance (and wire its
>> >> dependencies) but still have the shell know about it / how to talk to
>> >> it.
>> >
>> > The console looks for services in the registry.  The custom blueprint
>> > namespace is just a simple way to expose the service.
>> > To add a command to the console if you're no using blueprint, register a
>> > service implementing the org.apache.felix.service.command.Function
>> > interface
>> > and with the osgi.command.function and osgi.command.scope service
>> > properties.   Try "ls -a 14' for example in the karaf console to see a
>> > bunch
>> > of those methods.   The helper classes are located in the
>> > o.a.karaf.shell.console bundle.
>>
>> Great, thanks!
>>
>> >> - it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
>> >> online, whilst that would be handy to have
>> >
>> > Wanna raise a JIRA, that should be fixed.
>> > You can find it at
>> >
>> > http://svn.apache.org/repos/asf/karaf/tags/karaf-2.1.0/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell.xsd
>> > in the mean time.
>>
>> Will file a ticket
>>
>> >> - does what I am trying to do make any sense at all? (I'm rather new
>> >> to the latest OSGi spec, and am not sure what the usual practices are)
>> >
>> > What are you trying to do? Do you only need to register a set of
>> > commands
>> > using spring-dm ?  Do you really need to use the blueprint implemnttion
>> > from
>> > spring?
>>
>> Actually I don't care so much for the blueprint implementation. What I
>> am after is spring's dependency injection toolset and the integration
>> test facility
>> (http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/testing.html#testing:integration).
>> If I understood things right, I do need spring dm to be running on the
>> platform in order to get those, or not?
>>
>> Thanks,
>>
>> Manuel
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>
>
>

Re: Karaf and Spring DM 2

Posted by Guillaume Nodet <gn...@gmail.com>.
Note that @Autowired could be achieved by an explicit wiring in blueprint if
the bean has setters.

Let me know if you need more help, that's an are i'm interested in going to
the bottom, as I'm still unclear what works and what does not.

On Fri, Oct 15, 2010 at 22:24, Manuel Bernhardt
<be...@gmail.com>wrote:

> Salut!
>
> On Fri, Oct 15, 2010 at 7:19 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> > Yeah, that has changed in 2.1 where Karaf does not display the
> pre-installed
> > bundle anymore.
> > Try 'la' in the console to see all the bundles.  The Aries Blueprint impl
> is
> > used by a lot of bundles in karaf.
>
> Indeed. Well then I'll probably have some more surprises with the two
> Blueprint implementations running side-by-side
>
> >> The issue I have now is that we use the Karaf shell extensions in
> >> order to talk to our bundles via the console. This worked nicely with
> >> a <command-bundle> declaration as long as I didn't inject dependencies
> >> with spring (but wired them via hand). Now, spring not being the one
> >> initializing the shell <action> classes, the dependencies are not
> >> initialized.
> >
> > Not sure to exactly follow what you did with spring.
>
> Mainly the shell extension (extending OsgiCommandSupport) has a member
> that is injected via @AutoWired. The type is declared in the spring
> bundle context.
>
> >> - how does the shell console look for it's extension points? Will it
> >> only look in <command-bundle> definitions in a OSGI-INF/blueprint
> >> path, or would it in theory be fine if the definition were in a spring
> >> bundle-context definition file (with a custom namespace mapping). My
> >> aim would be to have spring initialize the instance (and wire its
> >> dependencies) but still have the shell know about it / how to talk to
> >> it.
> >
> > The console looks for services in the registry.  The custom blueprint
> > namespace is just a simple way to expose the service.
> > To add a command to the console if you're no using blueprint, register a
> > service implementing the org.apache.felix.service.command.Function
> interface
> > and with the osgi.command.function and osgi.command.scope service
> > properties.   Try "ls -a 14' for example in the karaf console to see a
> bunch
> > of those methods.   The helper classes are located in the
> > o.a.karaf.shell.console bundle.
>
> Great, thanks!
>
> >> - it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
> >> online, whilst that would be handy to have
> >
> > Wanna raise a JIRA, that should be fixed.
> > You can find it at
> >
> http://svn.apache.org/repos/asf/karaf/tags/karaf-2.1.0/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell.xsd
> > in the mean time.
>
> Will file a ticket
>
> >> - does what I am trying to do make any sense at all? (I'm rather new
> >> to the latest OSGi spec, and am not sure what the usual practices are)
> >
> > What are you trying to do? Do you only need to register a set of commands
> > using spring-dm ?  Do you really need to use the blueprint implemnttion
> from
> > spring?
>
> Actually I don't care so much for the blueprint implementation. What I
> am after is spring's dependency injection toolset and the integration
> test facility (
> http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/testing.html#testing:integration
> ).
> If I understood things right, I do need spring dm to be running on the
> platform in order to get those, or not?
>
> Thanks,
>
> Manuel
>



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

Re: Karaf and Spring DM 2

Posted by Guillaume Nodet <gn...@gmail.com>.
We have an integration testing framework in karaf based on pax-exam.
You can find some of our integration tests at
   http://svn.apache.org/repos/asf/karaf/trunk/itests/

On Fri, Oct 15, 2010 at 22:24, Manuel Bernhardt
<be...@gmail.com>wrote:

> Salut!
>
> On Fri, Oct 15, 2010 at 7:19 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> > Yeah, that has changed in 2.1 where Karaf does not display the
> pre-installed
> > bundle anymore.
> > Try 'la' in the console to see all the bundles.  The Aries Blueprint impl
> is
> > used by a lot of bundles in karaf.
>
> Indeed. Well then I'll probably have some more surprises with the two
> Blueprint implementations running side-by-side
>
> >> The issue I have now is that we use the Karaf shell extensions in
> >> order to talk to our bundles via the console. This worked nicely with
> >> a <command-bundle> declaration as long as I didn't inject dependencies
> >> with spring (but wired them via hand). Now, spring not being the one
> >> initializing the shell <action> classes, the dependencies are not
> >> initialized.
> >
> > Not sure to exactly follow what you did with spring.
>
> Mainly the shell extension (extending OsgiCommandSupport) has a member
> that is injected via @AutoWired. The type is declared in the spring
> bundle context.
>
> >> - how does the shell console look for it's extension points? Will it
> >> only look in <command-bundle> definitions in a OSGI-INF/blueprint
> >> path, or would it in theory be fine if the definition were in a spring
> >> bundle-context definition file (with a custom namespace mapping). My
> >> aim would be to have spring initialize the instance (and wire its
> >> dependencies) but still have the shell know about it / how to talk to
> >> it.
> >
> > The console looks for services in the registry.  The custom blueprint
> > namespace is just a simple way to expose the service.
> > To add a command to the console if you're no using blueprint, register a
> > service implementing the org.apache.felix.service.command.Function
> interface
> > and with the osgi.command.function and osgi.command.scope service
> > properties.   Try "ls -a 14' for example in the karaf console to see a
> bunch
> > of those methods.   The helper classes are located in the
> > o.a.karaf.shell.console bundle.
>
> Great, thanks!
>
> >> - it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
> >> online, whilst that would be handy to have
> >
> > Wanna raise a JIRA, that should be fixed.
> > You can find it at
> >
> http://svn.apache.org/repos/asf/karaf/tags/karaf-2.1.0/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell.xsd
> > in the mean time.
>
> Will file a ticket
>
> >> - does what I am trying to do make any sense at all? (I'm rather new
> >> to the latest OSGi spec, and am not sure what the usual practices are)
> >
> > What are you trying to do? Do you only need to register a set of commands
> > using spring-dm ?  Do you really need to use the blueprint implemnttion
> from
> > spring?
>
> Actually I don't care so much for the blueprint implementation. What I
> am after is spring's dependency injection toolset and the integration
> test facility (
> http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/testing.html#testing:integration
> ).
> If I understood things right, I do need spring dm to be running on the
> platform in order to get those, or not?
>
> Thanks,
>
> Manuel
>



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

Re: Karaf and Spring DM 2

Posted by Manuel Bernhardt <be...@gmail.com>.
Salut!

On Fri, Oct 15, 2010 at 7:19 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> Yeah, that has changed in 2.1 where Karaf does not display the pre-installed
> bundle anymore.
> Try 'la' in the console to see all the bundles.  The Aries Blueprint impl is
> used by a lot of bundles in karaf.

Indeed. Well then I'll probably have some more surprises with the two
Blueprint implementations running side-by-side

>> The issue I have now is that we use the Karaf shell extensions in
>> order to talk to our bundles via the console. This worked nicely with
>> a <command-bundle> declaration as long as I didn't inject dependencies
>> with spring (but wired them via hand). Now, spring not being the one
>> initializing the shell <action> classes, the dependencies are not
>> initialized.
>
> Not sure to exactly follow what you did with spring.

Mainly the shell extension (extending OsgiCommandSupport) has a member
that is injected via @AutoWired. The type is declared in the spring
bundle context.

>> - how does the shell console look for it's extension points? Will it
>> only look in <command-bundle> definitions in a OSGI-INF/blueprint
>> path, or would it in theory be fine if the definition were in a spring
>> bundle-context definition file (with a custom namespace mapping). My
>> aim would be to have spring initialize the instance (and wire its
>> dependencies) but still have the shell know about it / how to talk to
>> it.
>
> The console looks for services in the registry.  The custom blueprint
> namespace is just a simple way to expose the service.
> To add a command to the console if you're no using blueprint, register a
> service implementing the org.apache.felix.service.command.Function interface
> and with the osgi.command.function and osgi.command.scope service
> properties.   Try "ls -a 14' for example in the karaf console to see a bunch
> of those methods.   The helper classes are located in the
> o.a.karaf.shell.console bundle.

Great, thanks!

>> - it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
>> online, whilst that would be handy to have
>
> Wanna raise a JIRA, that should be fixed.
> You can find it at
> http://svn.apache.org/repos/asf/karaf/tags/karaf-2.1.0/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell.xsd
> in the mean time.

Will file a ticket

>> - does what I am trying to do make any sense at all? (I'm rather new
>> to the latest OSGi spec, and am not sure what the usual practices are)
>
> What are you trying to do? Do you only need to register a set of commands
> using spring-dm ?  Do you really need to use the blueprint implemnttion from
> spring?

Actually I don't care so much for the blueprint implementation. What I
am after is spring's dependency injection toolset and the integration
test facility (http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/testing.html#testing:integration).
If I understood things right, I do need spring dm to be running on the
platform in order to get those, or not?

Thanks,

Manuel

Re: Karaf and Spring DM 2

Posted by Guillaume Nodet <gn...@gmail.com>.
On Fri, Oct 15, 2010 at 19:08, Manuel Bernhardt
<be...@gmail.com>wrote:

> Hello!
>
> I'm a newcomer to Karaf, and would have a question regarding the
> integration with Spring DM 2. I have an existing Karaf/Blueprint
> project and would like to use spring DM as it offers advanced DI
> features as well as a nice way of performing integration testing.
>
> So I spent a good part of the day fighting (and understanding) how
> Spring DM deals with custom namespaces, and was able to deploy a
> bundle with Spring-DM 2.0 on Karaf. For doing so I created a custom
> provision file and registered spring dm 2 as a feature.
>
> Karaf 2.1 seems to come by default without Aries installed so I didn't
> have any conflicts occurring there (or so I think at least). I mean I
> didn't see Aries running when performing a osgi:list.
>

Yeah, that has changed in 2.1 where Karaf does not display the pre-installed
bundle anymore.
Try 'la' in the console to see all the bundles.  The Aries Blueprint impl is
used by a lot of bundles in karaf.

>
> The issue I have now is that we use the Karaf shell extensions in
> order to talk to our bundles via the console. This worked nicely with
> a <command-bundle> declaration as long as I didn't inject dependencies
> with spring (but wired them via hand). Now, spring not being the one
> initializing the shell <action> classes, the dependencies are not
> initialized.
>

Not sure to exactly follow what you did with spring.


>
>
> My questions thus would be:
>
> - how does the shell console look for it's extension points? Will it
> only look in <command-bundle> definitions in a OSGI-INF/blueprint
> path, or would it in theory be fine if the definition were in a spring
> bundle-context definition file (with a custom namespace mapping). My
> aim would be to have spring initialize the instance (and wire its
> dependencies) but still have the shell know about it / how to talk to
> it.
>

The console looks for services in the registry.  The custom blueprint
namespace is just a simple way to expose the service.
To add a command to the console if you're no using blueprint, register a
service implementing the org.apache.felix.service.command.Function interface
and with the osgi.command.function and osgi.command.scope service
properties.   Try "ls -a 14' for example in the karaf console to see a bunch
of those methods.   The helper classes are located in the
o.a.karaf.shell.console bundle.


>
> - it looks like http://karaf.apache.org/xmlns/shell/v1.0.0 isn't
> online, whilst that would be handy to have
>

Wanna raise a JIRA, that should be fixed.
You can find it at
http://svn.apache.org/repos/asf/karaf/tags/karaf-2.1.0/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell.xsdin
the mean time.

>
> - does what I am trying to do make any sense at all? (I'm rather new
> to the latest OSGi spec, and am not sure what the usual practices are)
>

What are you trying to do? Do you only need to register a set of commands
using spring-dm ?  Do you really need to use the blueprint implemnttion from
spring?


>
> Thanks!
>
> Manuel
>



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