You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/10/21 02:32:47 UTC
[GitHub] [camel-karavan] mrinalsharma opened a new issue, #500: Deployment with a Custom processor throws ClassNotFoundException error
mrinalsharma opened a new issue, #500:
URL: https://github.com/apache/camel-karavan/issues/500
I have created a custom processor by following the code in https://github.com/apache/camel-karavan/tree/main/karavan-demo/postman/project. When the project is deployed in minikube, the following error is seen
> 2022-10-21 02:27:45,052 ERROR [org.apa.cam.qua.mai.CamelMainRuntime] (main) Failed to start application: java.lang.RuntimeException: java.lang.ClassNotFoundException: Customprocessor
Processor Code:
```
import org.apache.camel.BindToRegistry;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
@BindToRegistry("Customprocessor")
public class Customprocessor implements Processor {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("Hello world");
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1293939418
I don't have any specific problem to solve, I was trying jbang/karavan capabilities. In my test case, pipeline looks like
Rest Consumer(with some string body) => sort( tokanize(\n))
Sort will return a sorted java.util.LinkedList and restResponse need an InputStream. That's why a converter is needed from List to InputStream.
BTW, Is there a way to Eagerly create a Bean, I am following the [steps ](https://quarkus.io/guides/lifecycle) but StartupEvent is not available during jbang export.
```
//DEPS io.quarkus:quarkus-core
import javax.inject.Inject;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import java.util.stream.Collectors;
import java.util.List;
import org.apache.camel.CamelContext;
import java.io.InputStream;
import org.apache.camel.TypeConverter;
import java.io.ByteArrayInputStream;
import java.util.LinkedList;
import org.apache.camel.Exchange;
import org.apache.camel.support.TypeConverterSupport;
import org.jboss.logging.Logger;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import javax.inject.Named;
import javax.inject.Singleton;
import javax.enterprise.event.Observes;
import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
@Singleton @Named("myconverter")
public class Ioconverter {
private static final Logger LOG = Logger.getLogger(Ioconverter.class);
CamelContext context;
@Inject
Ioconverter(CamelContext contex) {
this.context = context;
}
void startup(@Observes StartupEvent event) {
LOG.info("The application is starting...");
}
@PostConstruct
public void init() {
LOG.info("Adding converter");
context.getTypeConverterRegistry().addTypeConverter(java.io.InputStream.class, java.util.LinkedList.class, new MyConverter());
}
static class MyConverter extends TypeConverterSupport {
public <T> T convertTo(Class<T> type, Object value) {
// converter from value to the MyOrder bean
return (T) new java.io.ByteArrayInputStream("My Hello World".getBytes());
}
public <T> T convertTo(Class<T> type, Exchange exchange, Object value) {
// this method with the Exchange parameter will be preferd by Camel to invoke
// this allows you to fetch information from the exchange during convertions
// such as an encoding parameter or the likes
return convertTo(type, value);
}
public <T> T mandatoryConvertTo(Class<T> type, Object value) {
return convertTo(type, value);
}
public <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value) {
return convertTo(type, value);
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1287021548
How do you deploy this to minikube?
And can you tell us what versions of Camel / Quarkus you are using?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mgubaidullin commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mgubaidullin commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1288345651
https://issues.apache.org/jira/browse/CAMEL-18642
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1292442184
Not for your own custom java code that is just a file.
But for 3rd party JARs then you can use #class and #type to refer such as a JDBC driver class name etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1293755086
Oh for quarkus I think that they have camel code that detects `@Converter` when camel quarkus startup - but you can give it a try.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mgubaidullin commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mgubaidullin commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1287523847
Karavan project structure is flat.
So your Java class should not have a package, because it is not in the folder `com.demo.unknown`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1292417563
@davsclaus your suggestion has worked. As per the definition of ref property , is it possible to reference by #class or #type?
> Reference to the Processor to lookup in the registry to use. Can also be used for creating new beans by their class name by prefixing with #class, eg #class:com.foo.MyClassType. And it is also possible to refer to singleton beans by their type in the registry by prefixing with #type: syntax, eg #type:com.foo.MyClassType
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1287161656
To deploy Karavan, I have used documentation defined at https://github.com/apache/camel-karavan/tree/main/karavan-cloud. Unknown is the project name :)
- Then created a project
- Added a customprocessor
- Pressed deploy button
-
![image](https://user-images.githubusercontent.com/3838113/197239625-6f57723d-d8bb-47af-90bc-051ef5a86c91.png)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma closed issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma closed issue #500: Deployment with a Custom processor throws ClassNotFoundException error
URL: https://github.com/apache/camel-karavan/issues/500
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1293775485
@mrinalsharma its not as common to have custom type converters for your own camel apps, so I am curious what use-case you have for that. As I would like if possible to make it easier and better documented with jbang/karavan how to do that - in such case.
And less friction when moving to Spring Boot or Quarkus.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1293614618
Thank you for the clarification. How should we use add camel converters to camel Quarkus?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1290000057
Depending on the runtime you export as you should use their way of annotations
For example for quarkus
https://camel.apache.org/manual/camel-jbang.html#_using_quarkus_injection
The camel-quarkus does not understand classes annotated with the Camel BindToRegistry annotation - You need to use their @Named @Singleton combo.
If you make the processor as follows (then it can run in both jbang and quarkus)
```
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import javax.inject.Named;
import javax.inject.Singleton;
@Singleton @Named("CustomProcessor")
public class CustomProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("Hello world");
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1290120247
Your class should use the cdi annotations as shown above, then you can refer to the bean by the given name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1293597450
No the doc is being updated. And maybe in the future Quarkus will support them too, but in that world you should use cdi annotations, like in spring boot you should use spring boot annotations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1294869776
However this is not Karavan specific so lets closed this ticket. You can get general Camel help in the zulip chat room, or old fashioned mailing list
https://camel.apache.org/community/support/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1287397386
I am able to reproduce the problem by directly running jbang export:
```
jbang -Dcamel.jbang.version=3.18.2 camel@apache/camel export --local-kamelet-dir=${KAMELETS_DIR} --gav=com.demo:unknown:1.0-SNAPSHOT --runtime=quarkus
```
> melet-dir=${KAMELETS_DIR} --gav=com.demo:unknown:1.0-SNAPSHOT --runtime=quarkus
Generating fresh run data
org.apache.camel.FailedToCreateRouteException: Failed to create route validateSubscriber at: >>> process[ref:#class:com.demo.unknown.Customprocessor] <<< in route: Route(validateSubscriber)[From[direct:validateSubscriber] ->... because of No bean could be found in the registry for: #class:com.demo.unknown.Customprocessor. Cause: com.demo.unknown.Customprocessor
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1287197060
Ah thanks, yeah that is a bit weird as karavan should deploy this via camel-jbang that performs an _export_ where the code (Customprocessor) should be included in the src/main/java folder for quarkus to compile and use.
However something is not working, so we need to see if we can reproduce this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1293694326
Add both `@Singleton` and `@TypeConverter` I assume
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1292622094
closing, for solution review [comment ](https://github.com/apache/camel-karavan/issues/500#issuecomment-1290000057)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus closed issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus closed issue #500: Deployment with a Custom processor throws ClassNotFoundException error
URL: https://github.com/apache/camel-karavan/issues/500
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1287572129
My java class and integration didn't have a package, When it didn't work without a package, I tried to add a package.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mgubaidullin commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mgubaidullin commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1288338916
I have reproduced this issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] mrinalsharma commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
mrinalsharma commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1293583683
@davsclaus The documentation https://camel.apache.org/manual/camel-jbang.html#_dependency_injection_in_java_classes states that @org.apache.camel.BindToRegistry should works on all Runtimes, then why it didn't work on Quarkus. I tried @org.apache.camel.Converter, but even this annotation is not working.
Is this a bug?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-karavan] davsclaus commented on issue #500: Deployment with a Custom processor throws ClassNotFoundException error
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #500:
URL: https://github.com/apache/camel-karavan/issues/500#issuecomment-1294869079
Here is a type converter example
https://github.com/apache/camel-kamelets-examples/tree/main/jbang/type-converter
Beware that doing a type converter from List<?> means that become a type converter for all Lists. So you need to deal with that in mind, eg if the list contains String, Map, NodeMap, FooBar objects.
So you may want to transform the message body via processor / bean / setBody / transform EIPs instead where you can loop the list and transform that into a single object instance, such as String, byte[] or a combined JSonNode object or something.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org