Including camel-test-spring causes NoClassDefFoundError for DefaultParameterNameDiscoverer - apache-camel

I have a Camel project using Maven to build and manage dependencies. My project depends on Camel component versions 2.14.0. I've matched Spring dependencies with Camel and use Spring component versions 3.2.11.RELEASE. However, if I include camel-test-spring version 2.14.0 as a dependency in the test scope it pulls in both spring-beans version 4.0.7.RELEASE and spring-expression 4.0.7.RELEASE into the runtime scope, which result is my application throwing java.lang.NoClassDefFoundError: org/springframework/core/DefaultParameterNameDiscoverer. Oh, btw, the application boots from a Java main method with org.apache.camel.spring.Main.
Adding exclusions for both spring-beans and spring-expression into the POM dependency for camel-test-spring resolves the runtime exception but I'm not sure if this is the right thing to do. Does anyone have more insight into why camel-test-spring 2.14.0 depends on the 4.0.7.RELEASE versions of spring-beans and spring-expression when most (all?) the other Camel 2.14.0 components seem to depend on 3.2.11.RELEASE versions of Spring components?
Regards,
Matt

Please you camel-test-spring3 which support Spring 3.x instead of camel-test-spring (for Spring 4.0.x).

Related

Apache Camel 3.1.0 Logging Issue

While I was porting Apache Camel Version from 2.x to 3.1.0 with Camel REST DSL and Spring Boot, I am facing the below logging issue.
My logging key is defined in application.properties i,e mymessage=Hello World.
Inside route when I am using it as
.log(LoggingLevel.INFO, "${properties:mymessage}") [Works in both 2.x and 3.1.0]
.log(LoggingLevel.INFO, "{{mymessage}}") [Works only in 2.x]
My problem is I have lots of logging statements using {{xxx}} which is unfortunately not working during 3.1.0 upgrading process.
Am I missing any specific setting.
I tried using #PropertySource by putting the key in the separate file also tried it with spring cloud config nothing works.
Any help would be highly appreciated.
This has been solved and will be part of 3.2.0, see https://issues.apache.org/jira/browse/CAMEL-14651

Deploying camel spring application in Apache Karaf 4.2.0

I am trying to deploy camel spring application in apache karaf. I am using maven to resolve the dependencies. The application runs fine in Intellij but when I deploy the application (along with all the project dependencies) in karaf the application won't start.
Can anyone tell me what is the correct way to deploy camel spring application in karaf?
And also the best approach in resolving the project dependencies?
Camel-version: 2.16.5
Karaf: 4.2.0
If the application is not starting, then it might be waiting for some resolvable dependency. Check the log and install the dependency manually using feature:install. Also ensure all libraries are properly mentioned in pom.xml

camel blueprint force usage of log4j

Has anyone been able to use camel-blueprint together with logback? It seems that there are dependencies in camel blueprint which forces you to use log4j even though the log4j dependencies are removed from the pom. After running the project it starts to download the slf4j-log4j12 and then then complains of multiple bindings because it finds both log4j and logback.
I did the same with a camel java project and it worked fine to switch to logback. Does camel-blueprint force you to use log4j as its logging implementation?
Answer found via nabble forum in through discussion with the camel community. For more details go here:
http://camel.465427.n5.nabble.com/camel-blueprint-force-usage-of-log4j-td5772826.html#a5772852
Essentially there are certain dependencies in the maven plugin which uses log4j. For production in JBoss Fuse or Karaf, its Pax logging.

ServiceMix (FuseESB) fails to find Camel javascript support when jar starts up

When deploying a Camel route to FuseESB, as FuseESB tries to start up the jar file, it gives the following exception in the log:
Found initial references null for OSGi service (&(language=js)
(objectClass=org.apache.camel.spi.LanguageResolver))
This causes the bundle to enter a grace period for a few minutes, after which it times out and its status moves to failed. Note that I'm not using javascript in the application, but I assume it is loaded as part of loading Camel core.
Details of my setup:
Code in question is written using an OSGi blueprint xml file to define the beans.
Code is packaged as a jar, as opposed to an OSGi bundle.
Code is deployed by being dropped into the deploy directory so it is deployed by the FAB deployer.
I believe I have the relevant Camel features installed.
Output from features:list:
[installed ] [2.10.0.fuse-71-047] camel-script-javascript camel-2.10.0.fuse-71-047
[installed ] [2.10.0.fuse-71-047] camel-script camel-2.10.0.fuse-71-047
I have worked around this by:
reverting to a spring xml file to define the beans
packaging the code as a bundle, not a jar
I still don't understand why the Blueprint version didn't work, but the question is now less urgent than it was.
With FAB you should declare the dependencies to your Camel components in your pom.xml file, and use scope=provided.
See more details at: http://fuse.fusesource.org/bundle/overview.html

NoSuchMethodError for errorHandler when deploying into ServiceMix

I have a servicemix module, which is basicly a camel based route.
It works fine during development and also when deploying in older version of FUSE. However, when deploying in a later version of FUSE, I get
Caused by: java.lang.NoSuchMethodError:
com.company.integration.MyRouteBuilder.errorHandler(Lorg/apache/camel/builder/ErrorHandlerBuilder;)Lorg/apache/camel/builder/RouteBuilder;
I do not quite get why :-)
The old version used camel 2.6, the new uses Camel 2.9. Both have RouteBuilder.errorHandler as far as i can tell..
br
I wouldn't spend too much time trying to figure that out myself...I'd just start testing with the same version of Camel that I'm going to deploy it under...otherwise even if you get around this issue, others will likely pop up, etc.
If you do have a requirement to run multiple apps that depend on different versions of Camel, then OSGi supports this as long as install the necessary camel bundle versions and setup your applicaiton bundle manifests correctly, etc.
Reinstalling (or rather, recreating the instance) helped.

Resources