骆驼找不到" SFTP"在注册表和关闭组件 [英] Camel not finding "sftp" component in registry and shutting down

查看:233
本文介绍了骆驼找不到" SFTP"在注册表和关闭组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是骆驼,SFTP组件文件上传到SFTP服务器。
在code是简单的:

I'm using the camel-sftp component to upload a file to an SFTP server. The code is simple:

File source = new File(path);
final String sftpUri = "sftp://" + userId  + "@" + serverAddress + "/" + remoteDirectory+"?password="+pwd;
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
     @Override
     public void configure() throws Exception {
        from("file:/" + path).to(sftpUri);
     }
});
context.start();
Thread.sleep(10000);
context.stop();

不过,骆驼有找到SFTP组件的问题。激活调试日志骆驼它抱怨:

However, camel has problems finding the sftp component. Activating the debug logs in Camel it complains:

| 62 - org.apache.camel.camel-core - 2.13.2 | Using ComponentResolver: org.apache.camel.impl.DefaultComponentResolver@29668a43 to resolve component with name: sftp
| 62 - org.apache.camel.camel-core - 2.13.2 | Found component: sftp in registry: null
| 62 - org.apache.camel.camel-core - 2.13.2 | Apache Camel 2.13.2 (CamelContext: camel-16) is shutting down

任何想法,为什么骆驼是表现这种方式?事实上,运行在独立的应用中code(以方法的Java类)正常工作。
我可以看到:

Any ideas why Camel is behaving this way? In fact, running this code in a standalone application (a Java class with a main method) works correctly. And I can see:

11:22:13.237 [main] DEBUG o.a.c.impl.DefaultComponentResolver - Found component: sftp in registry: null
11:22:13.239 [main] DEBUG o.a.c.impl.DefaultComponentResolver - Found component: sftp via type: org.apache.camel.component.file.remote.SftpComponent via: META-INF/services/org/apache/camel/component/sftp

在Karaf的,虽然只出现在第一行,由于某种原因或其他它没有找到 META-INF /服务/组织/阿帕奇/骆驼/组件/ SFTP 和作为结果的SFTP组分未发现

Inside of Karaf, though, only the first line appears, for some reason or other it does not find META-INF/services/org/apache/camel/component/sftp and as a result the sftp component is not found.

推荐答案

如果您运行的骆驼里面的OSGi,您应该从骆驼核心OSGi的使用OSGi的CamelContext。再有就是几个步骤设置这个OSGi的。

If you run Camel inside OSGi, you should use the OSGi CamelContext from camel-core-osgi. And then there is a few more steps to setup this for OSGi.

虽然它往往更容易使用OSGi的蓝图应用程序,并在蓝图XML文件引导骆驼,它不正确此

Though its often easier to use a OSGi blueprint application and bootstrap Camel in the blueprint xml file, which does this correctly.

但对于Java的code的一些手工工艺。在即将到来的骆驼2.15版本有与OSGi和SCR(声明性服务)的工作,这使得它更容易使用的Java做code。与骆驼OSGi的一个新的骆驼可控硅元件骆驼SCR。

But for Java code its some manual process. In the upcoming Camel 2.15 release there is a new camel-scr component for working with OSGi and SCR (Declarative Services) which makes it easier to do java code with Camel in OSGi using camel-scr.

我会建议检查其电流源$ C ​​$ C灵感如何你可以设置骆驼OSGi的从Java code

I would suggest to check its current source code for inspiration how you can setup Camel in OSGi from Java code

https://github.com/apache/camel/tree/主/组件/骆驼SCR

这篇关于骆驼找不到" SFTP"在注册表和关闭组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆