SFTP proxy bean is not recognized in runtime only

Problem Description

When connecting to an FTP proxy from Studio, everything works fine. However, when the same Job is deployed to Karaf, it throws the following error:

 

16:22:59,342 | ERROR | ExtenderThread-6 | BundleApplicationContextListener  50 | 236 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=local_project.testaze, config=osgibundle:/META-INF/spring/.xml))16:22:59,342 | ERROR | ExtenderThread-6 | BundleApplicationContextListener  50 | 236 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=local_project.testaze, config=osgibundle:/META-INF/spring/.xml))org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route testaze_cTimer_1 at: >>> To[sftp://runtime@localhost:22/./upload/?password=123&disconnect=true&proxy=#myProxy] <<< in route: Route(testaze_cTimer_1)[[From[timer:cTimer_1?delay=1000]] ->... because of Failed to resolve endpoint: sftp://runtime@localhost:22/./upload/?disconnect=true&password=123&proxy=%23myProxy due to: Could not find a suitable setter for property: proxy as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: com.jcraft.jsch.Proxy with value #myProxy 
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1652)[158:org.apache.camel.camel-core:2.16.3] 
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:138)[163:org.apache.camel.camel-spring:2.16.3] 
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:340)[163:org.apache.camel.camel-spring:2.16.3] 
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)[224:org.apache.servicemix.bundles.spring-context:3.2.14.RELEASE_1] 
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)[224:org.apache.servicemix.bundles.spring-context:3.2.14.RELEASE_1] 
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:950)[224:org.apache.servicemix.bundles.spring-context:3.2.14.RELEASE_1] 
at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)[235:org.springframework.osgi.core:1.2.1] 
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)[235:org.springframework.osgi.core:1.2.1] 
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[235:org.springframework.osgi.core:1.2.1] 
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)[235:org.springframework.osgi.core:1.2.1]
.
.
.
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route testaze_cTimer_1 at: >>> To[sftp://runtime@localhost:22/./upload/?privateKeyFile=~/.ssh/id_rsa&preferredAuthentications=publickey&passiveMode=false&connectTimeout=6000&soTimeout=6000&timeout=5000&tempFileName=inprogress.${file:name}.filepart&disconnect=true&stepwise=false&proxy=#myProxy] <<< in route: Route(testaze_cTimer_1)[[From[timer:cTimer_1?delay=1000]] ->... because of Failed to resolve endpoint: sftp://runtime@localhost:22/./upload/?connectTimeout=6000&disconnect=true&passiveMode=false&preferredAuthentications=publickey&privateKeyFile=%7E%2F.ssh%2Fid_rsa&proxy=%23myProxy&soTimeout=6000&stepwise=false&tempFileName=inprogress.%24%7Bfile%3Aname%7D.filepart&timeout=5000 due to: Could not find a suitable setter for property: proxy as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: com.jcraft.jsch.Proxy with value #myProxy
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:944)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3260)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2983)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2814)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2810)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2833)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2810)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2779)[158:org.apache.camel.camel-core:2.16.3]
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:270)[164:org.apache.camel.camel-spring:2.16.3]
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)[164:org.apache.camel.camel-spring:2.16.3]
... 10 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: sftp://runtime@localhost:22/./upload/?connectTimeout=6000&disconnect=true&passiveMode=false&preferredAuthentications=publickey&privateKeyFile=%7E%2F.ssh%2Fid_rsa&proxy=%23myProxy&soTimeout=6000&stepwise=false&tempFileName=inprogress.%24%7Bfile%3Aname%7D.filepart&timeout=5000 due to: Could not find a suitable setter for property: proxy as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: com.jcraft.jsch.Proxy with value #myProxy

 

Root Cause

The behavior appears because the JARs imported in cConfig conflict with the ones that are already used in runtime.

 

Solution

Follow these steps to solve the issue:

  1. Launch Studio, then open the Route, navigate to the Dependencies tab, and uncheck the following Bundle from the Bundle-Classpath list:

    camel-ftp-2.16.3.jar
    jsch-0.1.53.jar
  2. Save the Route, then rebuild it as an OSGI bundle (kar) and place it in the deploy folder.

The Route should deploy as expected.

Version history
Revision #:
7 of 7
Last update:
‎01-22-2019 12:50 PM
Updated by: