javaapache-karafapache-aries

During the migration of a project using spring DM to Aries Blueprint, there is a problem that the bean property value cannot be properly converted


i'm doing migrate spring-DM to ariesblueprint

using java11 and karaf 4.2.14

In the meantime, aries blueprint faced the problem of not finding the appropriate converter for the value of context.xml, which defined the defaultLocalAddress of Apache Mina.

15:25:43.199 ERROR [features-3-thread-1] Unable to start container for blueprint bundle test/0.0.1.SNAPSHOT
org.osgi.service.blueprint.container.ComponentDefinitionException: Error setting property: PropertyDescriptor <name: defaultLocalAddress, getter: class org.apache.mina.transport.socket.nio.NioSocketAcceptor.getDefaultLocalAddress(), setter: [class org.apache.mina.transport.socket.nio.NioSocketAcceptor.setDefaultLocalAddress(class java.net.InetSocketAddress), class org.apache.mina.core.service.AbstractIoAcceptor.setDefaultLocalAddress(class java.net.SocketAddress)]
        at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:818) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:784) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:765) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:699) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666) ~[!/:1.10.3]
        at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81) ~[!/:1.10.3]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90) ~[!/:1.10.3]
        at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62) ~[!/:1.10.3]
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:108) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:810) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:784) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:765) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:699) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666) ~[!/:1.10.3]
        at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81) ~[!/:1.10.3]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:360) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:190) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:737) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:433) [!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:298) [!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:335) [!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:288) [!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:284) [!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:274) [!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintExtender.addingBundle(BlueprintExtender.java:237) [!/:1.10.3]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:487) [!/:1.10.3]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerAdding(BundleHookBundleTracker.java:433) [!/:1.10.3]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackAdding(BundleHookBundleTracker.java:749) [!/:1.10.3]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.trackInitial(BundleHookBundleTracker.java:674) [!/:1.10.3]
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker.open(BundleHookBundleTracker.java:159) [!/:1.10.3]
        at org.apache.aries.util.tracker.RecursiveBundleTracker.open(RecursiveBundleTracker.java:106) [!/:1.10.3]
        at org.apache.aries.blueprint.container.BlueprintExtender$2.serviceFound(BlueprintExtender.java:138) [!/:1.10.3]
        at org.apache.aries.util.tracker.SingleServiceTracker.update(SingleServiceTracker.java:174) [!/:1.10.3]
        at org.apache.aries.util.tracker.SingleServiceTracker.findMatchingReference(SingleServiceTracker.java:132) [!/:1.10.3]
        at org.apache.aries.util.tracker.SingleServiceTracker.access$200(SingleServiceTracker.java:32) [!/:1.10.3]
        at org.apache.aries.util.tracker.SingleServiceTracker$1.serviceChanged(SingleServiceTracker.java:61) [!/:1.10.3]
        at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4595) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.Felix.registerService(Felix.java:3587) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:322) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.aries.proxy.impl.ProxyManagerActivator.start(ProxyManagerActivator.java:66) [!/:1.1.12]
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2240) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2146) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984) [org.apache.felix.framework-5.6.12.jar:?]
        at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165) [!/:?]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1154) [!/:?]
        at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1044) [!/:?]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1063) [!/:?]
        at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) [!/:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: No converter available to convert value :8000 into a form applicable for the setters of property defaultLocalAddress
        at org.apache.aries.blueprint.utils.ReflectionUtils$MethodPropertyDescriptor.internalSet(ReflectionUtils.java:672) ~[!/:1.10.3]
        at org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.set(ReflectionUtils.java:418) ~[!/:1.10.3]
        at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:816) ~[!/:1.10.3]
        ... 60 more

It's part of my network-context.xml.

<bean id="ioAcceptor" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor">
    <property name="defaultLocalAddress" value=":8000"/>
    <property name="handler" ref="minaHandler"/>
    <property name="reuseAddress" value="true"/>
    <property name="filterChainBuilder" ref="filters"/>
</bean>

It worked well in SpringDM.

The phrase itself doesn't seem to change, so I'm using it as it is.

Is there anything that I forgot or did something foolish?

If the question is strange or foolish, please let me know.


Solution

  • I don't think Aries supports natively type converter to InetSocketAddress.

    You can create explicitly a new instance of a InetSocketAddress:

    <bean id="ioAcceptor" class="org.apache.mina.transport.socket.nio.NioSocketAcceptor">
        <property name="defaultLocalAddress" value=":8000">
          <bean class="java.net.InetSocketAddress">
            <argument value="8000"/>
          </bean>
        <property name="handler" ref="minaHandler"/>
        <property name="reuseAddress" value="true"/>
        <property name="filterChainBuilder" ref="filters"/>
    </bean>
    

    or register your own type converter.

    You should implements org.osgi.service.blueprint.container.Converter and register it with <type-converter>

    See: