apache-camel,apache-karaf , Camel not finding “sftp” component in registry and shutting down


Camel not finding “sftp” component in registry and shutting down

Question:

Tag: apache-camel,apache-karaf

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();

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: [email protected] 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

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

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.


Answer:

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.

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

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.

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/master/components/camel-scr


Related:


Camel Thread Id changing when calling http component


java,redis,apache-camel
My route is like this: from(rabbitmq). to(redisLockerProcessor). to(processor1). to(ahc://http:).to(processor2) .to(redisLockReleaseProcessor) I am using redisson library which stores thread id which took the lock in redis. But in redisLockReleaseProcessor it is throwing exception that thread id is not same as thread id which took the lock. How does http components thread...

Camel pollEnrich and xml 'prettyPrint'


apache-camel
I am attempting to use Camel's pollEnrich feature, but it is not behaving as I would like... I'm not saying it's broken, but wondering if there is a way to get the behavior I desire. That is, I have an XML (blueprint) defined route that goes something like this: <route>...

What exactly does multicast() do?


apache-camel
What's the exact difference between from("stream:in") .to("stream:out", "stream:err"); and from("stream:in") .multicast() .to("stream:out", "stream:err"); ?...

Camel requestBodyAndHeaders() doesn't return the route result


apache-camel
I have a Camel route with split/aggregate: from("seda:start") .routeId("camelRoute") .log("Request: ${body}") .split() .method(SplitService.class, "splitRequest") .parallelProcessing() .bean(SendToWorker.class, "sendToQ1(${body}, ${headers})") .aggregate(header("corrID"), new CustomAggregationStrategy()).completionSize(5) .log("Aggregated ${body}") .bean(SendToWorker.class, "sendToQ2(${body}, ${headers})") .log("Response: ${body}"); The last log displays the result correctly. When I call it as @Autowired private ProducerTemplate...

apache camel route to split sql results


mysql,jdbc,apache-camel
I am trying to do is select all rows from DB, and for each row update some column for that row. Below is my camel route. from("direct:insert"). from("sql:select * from my_table"). split(body()). log("${body[id]}"). end(); I use the below code to start this route... context.createProducerTemplate().sendBody("direct:insert", null); Problem is it happens multiple...

Does ActiveMQ support multiple transactional consumers?


transactions,apache-camel,activemq,servicemix
I am developing OSGI bundles in ServiceMix to consume from the same queue of ActiveMQ. I need to be sure that the message is dequeued only if every thing goes fine so that I don't lose that message. So I used camel transactional client. I manged to implement it by...

Camel Multicast; Direct and AMQ


java,web-services,soap,apache-camel,activemq
I have a Generic Camel Route which listens to a CXF:Bean(SOAP) Request with DataFormat: POJO. What I want this route to do is multicast the incoming exchange to AMQ JMS Queue, which will be consumed by another internal route at a later point and the other endpoint is a direct:Endpoint...

Automatic conversion to JSON when using ProducerTemplate


apache-camel
I would like to send JMS messages containing Java POJOs to ActiveMQ and all messages should be converted to JSON documents. So I need mechanism that will convert POJO to JSON and will send created document as text message to ActiveMQ. I would like to use ProducerTemplate#send(...) method without need...

Automatically restore connection to the main queue when server is up again


java,jms,apache-camel,websphere-mq
I have a master MQ and a slave MQ. If the master MQ goes down, can I send the messages through the slave MQ using a message driven bean ? Also after my master MQ is up again can I reconnect the line automatically without restarting the JVM ?

Apache Camel CXF


java,soap,apache-camel
Camel Configuration was working fine with v 2.13.4. After migrating to v 2.15.1 I am getting following error: Caused by: org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.camel.component.cxf.spring.NamespaceHandler] for namespace [http://camel.apache.org/schema/cxf]: problem with handler class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/apache/camel/component/cxf/spring/NamespaceHandler, offset=6 at...

Camel Delete File Exception


java,file,apache-camel
When I am trying to process a file in Camel and it fails I try to move the file to an error directory but get the following error message: org.apache.camel.component.file.GenericFileOperationFailedException: Cannot delete file:.... I don't know if Windows is locking the file, but I have closed any streams that may...

Camel Wiretap Error Handling


java,apache-camel
I am new to camel (v 2.10.0) and searching for a problem that i have due to exceptions that we throw in routes which are called by wireTap(). PROBLEM: is that when exception are thrown from wiretap routes then error handling do not run for these exceptions. When we change...

Camel netty component example doesn't work, within Spring MVC


spring,apache-camel,netty
I've tried out a good looking example in this topic ( http://shengwangi.blogspot.hu/2015/01/camel-netty-hello-world-simple-example.html ), but it doesn't work for me. I would like to create an simple workable TCP adapter, which uses an own encoder and decoder. At first I check out above example ( it uses a simple String encoder...

CamelContext doesn't startup if one route is misconfigured


java,apache-camel
We use Java DSL to configure our routes. All configurations for routes are in a db table and can be configured via a GUI. How is it possible to ensure that the camelContext starts up even if a route is misconfigured (e.g. .to(invalidurl or typo) in a route or simply...

Changing default settings for JMS messaging in Camel


apache-camel
I've found only a way to specify JMS settings directly on end points, but I would like to change default values, so that we do not have to remember to set the same value on each endpoint. Below there are few examples of properties which I would like to set...

Apache Camel FTP component from a web application


ftp,apache-camel
I have an apache camel based web application. I have created restful routes using the camel servlet component. I have a requirement where I want to download a file from FTP to the local server when one of the restful URL in my application is invoked. I couldn't find any...

Camel Redirecting to another route on throttling


apache-camel,throttling
I have a camel route which will be throttled on recieving loads of messages. Suppose the maximum exchanges i defined is 3 per 2 seconds and the route recieves more than the limit i want to redirect those messages to some other load balancer route. Can someone help me how...

Multiple Connection Factories


java,spring,apache-camel,activemq,javabeans
I'm using spring boot and setting up multiple connection factories (pooled and jms). The issue I'm getting is that it seems to be trying to autowire them to the same object in javax.jms.ConnectionFactory. So its resulting in this exception: Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.jms.ConnectionFactory org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration.connectionFactory; nested...

Camel file component URI format


java,apache-camel
Camel file component supports two notations for URI format: file:directoryName[?options] file://directoryName[?options] Why does the second one exist? It is less readable, especially when using Unix-like absolute paths, which is a frequent use case. In general, should I give preference to one over the other?...

Toggle for wiretap queue in Camel


java,apache-camel
Currently I'm using a choice() to determine if the toggle for the wiretap queue is switched on. Is there a better way to do it in Camel ? This is my code: package routes; import org.apache.camel.builder.RouteBuilder; public class MyRoute extends RouteBuilder{ private String inQueue; private String outQueue; private String wiretapQueue;...

No component found with Camel Bean Validator


java,validation,apache-camel,bean-validation
I am getting in route: Route(directRoute)[[From[direct-vm:getAddress]] -> [To[bean-v... because of Failed to resolve endpoint: bean-validator://validator?validationProviderResolver=myValidationProviderResolver due to: No component found with scheme: bean-validator I have added the following dependency : <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.1.0.Final</version> </dependency> <dependency>...

How to access exception in Camel errorHandler?


java,exception-handling,apache-camel
Use Case I'd like to log unhandled exceptions for a particular route in Camel in a reusable manner. Specifically, I'd like to extract enough information from the exception and write it to the database, which is then read by some monitoring software. Through the use of a dead letter queue,...

Is there a way I can autowire a bean in my route without using the .bean keyword in Camel?


java,spring,apache-camel,javabeans,autowired
Lets say for example, I have the following route: from(.....) .choice() .when(condition1) .bean(Class1.class,"method1") .when(condition2) .bean(Class1.class,"method2") .otherwise() .bean(Class1.class,"method3") .end(); Is there a way I can autowire Class1 to use all the methods instead of using the .bean function in camel. If you know any other efficient method. Please do let me...

Database not update when using apache camel sql component


apache-camel
I'm trying to use apache camel (sql component) to update the DB. Problem is that the DB just doesn't get updated. The sql:update is working fine when i hard code the query, but when i try to use ${body[0][id]} it doesn't update required field. Any feedback on what might be...

Cannot connect to websocket server using AHC-WS component in Apache Camel


apache-camel,slack-api
I'm using ACH-WS component in Apache Camel to connect to a websocket server using WSS (Slack's websocket server to be more precise). I have a route like this one: from("ahc-wss://host") .log(...) .to(...) When I init my app I see the following log: Route: wss-inbound-event started and consuming from: Endpoint[ahc-wss://ms109.slack-msgs.com/websocket/....] However...

Can anyone tell me how to test my Camel Route if I have a choice operation?


java,unit-testing,testing,apache-camel
I have a Camel route that has implemented a Content based Routing EIP(Choice operation). I need to test it. I'm new to Camel. So, I'm unsure how to do it. Can anyone tell me how to test this operation. I have mentioned a sample code below that has to be...

Getting Apache Camel to stop retrying if failed to move the file after route completion


java,file-io,exception-handling,locking,apache-camel
The example route below picks up a file and performs a series of operations on them. Once completed, as noted in the camel:from field, the route is instructed to move the file to a .processed directory. Alternatively if failed, move it to the .error folder. The problem occurs when another...

Mocking test class Spring camel


junit,apache-camel,spring-test
I am new to camel. I am trying to write a test case. public class A { private B b; public void update(String s){ //calling some methods on B ..... } } Test class public class TestA extends CamelSpringTestSupport { private ClassPathXmlApplicationContext xmlAppContext; @Test public void testA() { String xml...

Failed to deploy quickstart to Fabric8 on Jube


java,maven,apache-camel,jbossfuse,fabric8
I'm running Fabric8 2.1.5 version with Jube on my local Win7 PC, and trying to follow the documentation to deploy the Camel-Spring quickstart When I run "mvn fabric8:deploy" under quickstarts/java/camel-spring folder, I got the following error: [ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:2.1.5:deploy (default-cli) on project quickstart-java-cam el-spring: Error executing: Failed...

Why does Jasypt try to decrypt Camel Property Placeholders, regardless of the ENC( prefix?


apache-camel,jbossfuse,jasypt,blueprint-osgi,blueprint
In my Blueprint application deployed in JBoss Fuse 6.1.0-379, I want to secure the password I use for creating a database connection. I read this article and added <enc:property-placeholder> to the blueprint configuration. However my blueprint configuration has many property placeholders, and it seems that the Jasypt Placeholder Resolver is...

JBoss Fuse container: Karaf or Wildfly


apache-camel,jbossfuse
What is the recommended container for JBoss Fuse 6.1: Apache Karaf or JBoss Enterprise Application Server? Since things like datasource configuration are much easier in an application server environment compared to that of Karaf, I am tilted towards Wildfly. But I am unsure if the choice of Wildfly is at...

Best way to debug OSGI bundles in Karaf


eclipse,apache-karaf,osgi-bundle,karaf
To date, I've been successful at building OSGI bundles, and invoking web services defined in these bundles via Apache CXF. Next, I'd like to be able to set breakpoints in my bundles as they are executed within the Karaf environment. I've looked into EIK, but it doesn't seem that project...

Java & Apache-Camel: From direct-endpoint to file-endpoint


java,apache-camel
I've tried to build a route to copy files from one directory to an other directory. But instead of using: from(file://source-directory).to(file://destination-directory) I want to do something like this: from(direct:start) .to(direct:doStuff) .to(direct:readDirectory) .to(file://destination-folder) I've done the following stuff: Route @Component public class Route extends AbstractRouteBuilder { @Override public void configure() throws...

Pros and Cons of setting Lot of headers in Camel Exchange


apache-camel
I would like to know few things about Camel Headers what are the pros and cons of setting too many headers in camel Exchange? what are the pros and cons of setting too large headers in camel Exchange? ...

Sending mail with a custom MIME Message using Camel


java,email,apache-camel,spring-integration
I want to send a multipart MIME message (custom headers, plain text and HTML) using Camel. I can see in the source code that if I send a javax.mail.internet.MimeMessage in the body of a Camel message to the mail component, it send it without creating a new one. But in...

Why Does This Apache Camel Route Not Convert JSON to XML?


java,json,xml,apache-camel
I am trying to convert some JSON to XML using an Apache Camel route. Below is the code with the route in it, listing 1. The code that calls this code is the second source code segment, listing 2. The JSON that I want to convert to XML is in...

just install jboss-fuse but management console is not reachable


apache-karaf,jbossfuse
I have install jboss-fuse on linux centos and runt it. But management console is not reachable. I have found some relevant documentation on redhat's website and followed the steps. https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/Using_the_Management_Console/files/FMCUGAccess.html In that document it is said fabric-webui is to be installed. So I have run this command; "profile-edit --features fabric-webui...

How to load external properties file through OSGi blueprint property-placeholder and Java DSL


java,apache-karaf,servicemix,blueprint-osgi
I have a bundle installed in Apache servicemix that is using apache blueprint for configuration. I am using an external properties file abc.cfg located in /config folder and is being loaded as follows: via blueprint <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel-cxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/blueprint/core" xsi:schemaLocation=" http://cxf.apache.org/jaxrs...

Extract data from JSON in vanilla Java/Camel/Spring


apache-camel,activemq,jolokia
I am trying to write a Camel route to get JMX data from an ActiveMQ server through the Jolokia REST API. I was able to successfully get the JSON object from the ActiveMQ server, but I am running into an issue where I cannot figure out how to parse the...

How To Disable Camel HTTP Endpoint Stream Caching When Using Servlet in OSGi


apache-camel
I'm using an Apache Camel route to receive incoming HTTP traffic using the servlet component. The route is very simple: <camel:route id="peopleSoftServletService" errorHandlerRef="errorHandler"> <camel:from uri="servlet:///PeopleSoftService" /> <camel:setHeader headerName="origin"> <camel:simple>PeopleSoft Server: ${in.header.X-Forwarded-For}</camel:simple> </camel:setHeader> <camel:inOnly uri="activemq:peoplesoft" /> </camel:route> I'm encountering problems with stream caching. I'm not...

Camel Multi-threaded Consumer


java,multithreading,apache-camel,producer
I have a DB with orders, each with a due date and a creation date. I want to pull a maximum of 4 orders into route and process them simultaneously. Each order may take between 10-20 minutes to process. But I would like to keep all threads going as much...

Refactoring some legacy camel code, is this code unnecessary or am I missing something?


jboss,apache-camel,jbossfuse
I'm refactoring some apache camel legacy code in a JBoss Fuse instance and I've run into some code that I'm not sure what it's purpose is for. <when condition> <loadBalance id="someVar"> <failover roundRobin="true" maximumFailoverAttempts="3" /> <to uri="fabric:FABRICENDPOINT" /> </loadBalance> </when> I haven't used Fabric's load balancer before but from what...

Where is this variable coming from in this Apache Camel program?


java,apache-camel
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you...

Camel JMS - does it pull messages from queue in a loop?


apache-camel,activemq
I've enabled JMS transactions as described in this document: http://camel.apache.org/transactional-client.html My queue subscriber is registered as follows: from("jms:queue:xyz).to(MyBean.class) There are no messages on this queue, but I can see in Camel log, that it starts and ends multiple JMS transactions and this happens multiple times with different thread id. This...

Camel ProducerTemplate not injected with annotation config


java,spring,apache-camel,activemq
First of all, I know there are very similar questions (Camel producerTemplate is not injected in spring MVC and Initializing camel from Spring annotation config) but they don't help in my case. I have a bean which sends messages with ProducerTemplate: public class SimpleProducer { @Produce(uri = "activemq:queue:simple") private ProducerTemplate...

Throttle requests in camel not working


groovy,apache-camel,throttle,eip
Below are my 3 routes in my base groovy routes class deployed as base framework. from("jms:queue:EndPoint1?concurrentConsumers=100") .routePolicyRef("myPolicy") .transacted() .log("Recieved From Endpoint1") /*.to("log:Recieved From Endpoint1?groupSize=100")*/ .to("CommonEndpoint"); from("jms:queue:EndPoint2?concurrentConsumers=50") .rootPolicyRef("myPolicy") /*.to("log:Recieved From Endpoint2?groupSize=100")*/ .log("Recieved From Endpoint2") .to("CommonEndpoint"); from("CommonEndpoint") .delay(50)...

Generate Javadoc for OSGi bundle


apache-camel,javadoc,servicemix,osgi-bundle,maven-javadoc-plugin
I'm newbie in OSGi world but I was able to do some Camel and OSGi bundles to do some tasks in a middleware. Everything I made since was a proof of concept, but now I want to refactor some part of my code and I start writing a OSGi bundle...

How to transfer files in order (first come first serve) using apache camel


spring,apache-camel
In my code there are two types of files with extension .csv or .psv and .tigger files. .csv files have more size than .trigger files, so .trigger files are getting transfer in prior to .csv files. How to make sure that once .csv files are transferred only .trigger files should...

Camel consume single message and stop, transacted


java,transactions,apache-camel,consumer,once
I am trying to use Camel to consume a single message from a JMS queue in a transacted manner. Specifically in a flow like this: Wait until message is published on JMS queue Try to consume and process the single message If processing fails (exception occurs), rollback the consumption If...

Karaf / Maven - Unable to resolve: missing requirement osgi.wiring.package


java,maven,gson,apache-karaf
I am unable to start a bundle in Karaf (version 3.0.1). The bundle is built using maven and it imports gson. I included gson in maven as required: <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.3.1</version> </dependency> The build goes fine. However, when deploying the bundle I receive this Warning from Karaf: 2015-05-27 12:45:07,371...