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

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

Related

Running a Spring Boot Camel inside Jboss Fuse

I have a application running Spring Boot Camel which consume message from a ActiveMQ and write to a file:
#Override
public void configure() throws Exception {
from("activemq:queue:MyQueue").to("file:/tmp/somemessages/");
}
Very simple and works fine if run mvn spring-boot:run.
But now i need generate a bundle jar to install in my RedHat Fuse OSGi container. Everything was installed and started without error, see:
So, my camel-app is Active but after produce some messages in my ActiveMQ Queue nothing works as i expect, so the file was not generated.
How can i see if something is wrong ? Application Console Log or something like this ?
This is not a good practice. Spring Boot is intended for running Standalone. In an OSGi based runtime such as Red Hat Fuse or Apache Karaf/ServiceMix you should deploy OSGi apps, which with Camel is camel-blueprint (you can also use Java routes with blueprint). So take a look at examples how to do that, and there should be examples shipped with Red Hat Fuse you can look at.
How can i see if something is wrong ? Application Console Log or something like this ?
The simple answer is you can run diagnostic command on your bundle by running following command inside your shell console:
bundle:diag {your-bundle-id}
You may replace {your-bundle-id} by preferred bundle id that is 231 in the picture. There is also a complete list of Apache Karaf commands that may be useful for further requirements.

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.

deploying camel java-archetype projec to Fuse 6.2

I have created a java-archetype project for Camel. It is a simple REST hello world to receive a get request and return a string body. When I run this as Java application from Eclipse it works as intended.
When I take the jar and deploy it the Fuse "deploy" folder I can see in the logs that the bundle has started. The state is active and green. However the Camel tab does not appear.
The same works if I use blueprint but does not seem to do so using the java dsl. Is there an extra magic code you need to add for Fuse to pick up the camel context? Thanks
Yes for OSGi to startup you can use a spring or blueprint with a <camelContext> that starts Camel. If you use pure Java code you have to fight with OSGi and use an OSGI activator and setup all kind of OSGi stuff that gets you tiresome.
So add a blueprint xml file and add the <camelContext> and then you can refer to Java route builders, just as you can when doing spring xml: http://camel.apache.org/spring.html

Not able to start the bundle in servicemix

I have a bundle up and running in Servicemix. I went to my company's repository and downloaded the corresponding JAR to my local machine. I extracted that JAR and found out that this JAR had only one folder META-INF.
Inside this folder, there is a Manifest.mf file and my resources such as Spring configuration file and Camel Context file.
there I got my first question: where are the source files of this JAR i.e. JAVA classes and all. Only thing I saw there was manifest file, pom.xml, another pom properties file and couple of other configuration files for spring and camel.
this led to my next step. I had a local copy of this project in my workspace as well. I build this project locally and found the JAR in target directory of the project.
Now following steps might seem silly but anyway I did little experiment. I extracted this JAR which I found in target and extracted it to see the content. I believed it was a bundle because I used maven-bundle-plugin and there is no way you could tell by looking at a JAR that its just a JAR or an OSGI bundle. ok so I extracted the JAR and guess what this time it did have the compiled java classes.
this is not the end, I did something silly again. I removed the compiled classes from this JAR and made it exactly same as which I copied from my Company's central repository. Now I used a JDK's JAR creation utility to create a JAR.
Now I have two JARS:
one which I downloaded from company's central repo.
another one which I created myself. it has exactly same content as the other one. I even used the same manifest.mf while creating this JAR. (Since I knew Manifest is the backbone of an oSGI Bundle).
I secure copied this bundle in my server's home directory. and finally, I installed this Bundle/JAR in Servicemix using :
install file:path_to_JAR/JAR_FILE_NAME.
it got installed successfully. but when I tried to start this bundle. it could not start. by using display-exception, I saw the exception : it wasnt able to load the beans and could not
initialize the Application Context followed by a more specific exception "ClassNotFound" exception. I understand that it wasnt able to find the classes defined in my application context. BUT WHYYYYYYYYYY?
I did exactly same steps and I checked it multiple times. if mine could not start, why the earlier one is up and running.
It might sound silly for others who have worked in OSGI environment, But now I am starting to re consider especially ServiceMix.
Thanks for any suggestion.
This is nothing about OSGi, it's more something about your application.
As I don't know your project I just can do some assumptions.
First the jar you got from the Company Repository is most likely an "older" version and not the same as your local sources. With Servicemix it's quite possible to just have blueprint or spring xmls in your bundle cause those are valid resources a Camel-Blueprint/Spring extender are able to pick up. Those XMLs are interpreted and if those only make use of standard Camel Components there is no reason to have a single Class inside your bundle.
Now back to your newly created Bundle, obviously you have some new "Code" in your camel-xml which requires not only standard Camel classes but also some Processes you created on your own, now those classes need to stay in the Bundle!
Best just deploy the newly created Bundle with all it's classes. You should rather check what has changed in the camel xml files.

Resources