apache-camelesbapache-servicemixfuseesbapache-mina

Fuse ESB: Bundle with mina cannot be deployed in ServiceMix


I'm trying to use apache mina with camel on fuse esb. I'm facing to a deployement issue.

Here is my route :

<beans xmlns...
    <bean id="myCodec" class="test.net.mina.codec.MyMinaCodec" />
    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="mina:tcp://localhost:3100?sync=false&amp;codec=#myCodec" />
            <to uri="activemq://Test.IncomingMsg" />
        </route>
    </camelContext>
</beans>

Bellow is the stacktrace got from the servicemix console :

Exception in thread "SpringOsgiExtenderThread-18" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route8: Route[[From[mina:tcp://localhost:3100?sync=false&codec=#myCo... because of Failed to resolve endpoint: mina://tcp://localhost:3100?codec=%23myCodec&sync=false due to: Could not find a suitable setter for property: codec as there isn't a setter method with same type: test.net.mina.codec.MyMinaCodec nor type conversion possible: No type converter available to convert from type: test.net.mina.codec.MyMinaCodec to the required type: org.apache.mina.filter.codec.ProtocolCodecFactory with value test.net.mina.codec.MyMinaCodec@8073d3
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1149)
    at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:110)
    at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:240)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)
    at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
    at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
    at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route8: Route[[From[mina:tcp://localhost:3100?sync=false&codec=#myCo... because of Failed to resolve endpoint: mina://tcp://localhost:3100?codec=%23myCodec&sync=false due to: Could not find a suitable setter for property: codec as there isn't a setter method with same type: test.net.mina.codec.MyMinaCodec nor type conversion possible: No type converter available to convert from type: test.net.mina.codec.MyMinaCodec to the required type: org.apache.mina.filter.codec.ProtocolCodecFactory with value test.net.mina.codec.MyMinaCodec@8073d3
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:170)
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:698)
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1679)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1464)
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1356)
    at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:169)
    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1324)
    at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:213)
    at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:108)
    ... 10 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: mina://tcp://localhost:3100?codec=%23myCodec&sync=false due to: Could not find a suitable setter for property: codec as there isn't a setter method with same type: test.net.mina.codec.MyMinaCodec nor type conversion possible: No type converter available to convert from type: test.net.mina.codec.MyMinaCodec to the required type: org.apache.mina.filter.codec.ProtocolCodecFactory with value test.net.mina.codec.MyMinaCodec@8073d3
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:444)
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:48)
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:180)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:110)
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
    at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:72)
    at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:88)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:798)
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
    ... 20 more
Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter for property: codec as there isn't a setter method with same type: test.net.mina.codec.MyMinaCodec nor type conversion possible: No type converter available to convert from type: test.net.mina.codec.MyMinaCodec to the required type: org.apache.mina.filter.codec.ProtocolCodecFactory with value test.net.mina.codec.MyMinaCodec@8073d3
    at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:341)
    at org.apache.camel.util.EndpointHelper.setReferenceProperties(EndpointHelper.java:250)
    at org.apache.camel.impl.DefaultComponent.setProperties(DefaultComponent.java:199)
    at org.apache.camel.component.mina.MinaComponent.createEndpoint(MinaComponent.java:92)
    at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:426)
    ... 28 more

And here is my codec factory :

public class MyMinaCodec implements ProtocolCodecFactory {

    public ProtocolDecoder getDecoder(IoSession session) throws Exception {
        return new MyMinaDecoder();
    }

    public ProtocolEncoder getEncoder(IoSession session) throws Exception {
        return new MyMinaEncoder();
    }
}

Any idea of what I'm doing wrong here? Thanks for your help


Solution

  • Ok, its my bad! I forgot to specify the required bundle inside pom.xml for maven :

    <Require-Bundle>org.apache.servicemix.bundles.mina</Require-Bundle>