11 Replies Latest reply on Jun 12, 2009 10:49 AM by rodehav

    No camel converters found in Servicemix 4.1

    rodehav

      I have great problems using camel in combination with Servicemix 4.1.0.0. The actual routes work but no converters are found. I get this in the Servicemix log:

       

      09:19:32,156 | DEBUG | Component@b243d7 | ResolverUtil                     | g.apache.camel.util.ResolverUtil  261 |

       

      Searching for annotations of org.apache.camel.Converter in packages:

      09:19:32,156 | DEBUG | Component@b243d7 | ResolverUtil                     | g.apache.camel.util.ResolverUtil  291 | Using

       

      only regular classloaders

      09:19:32,156 | DEBUG | Component@b243d7 | ResolverUtil                     | g.apache.camel.util.ResolverUtil  291 | Using

       

      only regular classloaders

      09:19:32,156 | DEBUG | Component@b243d7 | ResolverUtil                     | g.apache.camel.util.ResolverUtil  271 | Found:

       

      []

       

       

      It seems like the right packages are searched but no converters are found. I have custom converters in org.apache.camel.fix  but the standard converters in org.apache.camel.converter are not found either. Previously in the log I get the following:

       

      09:13:09,050 | DEBUG | lixDispatchQueue | camel-core                       | ?                                   ? |

       

      BundleEvent STARTED

      09:13:09,050 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator   169 | checking

       

      existing bundles

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/bean in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/dataset in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/direct in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/file in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/list in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/log in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/mock in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/pojo in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/queue in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/ref in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/seda in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/timer in bundle org.apache.camel.camel-core

      09:13:09,143 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/vm in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/language/bean in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/language/constant in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/language/file in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/language/header in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/language/simple in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/language/xpath in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator   121 | Found

       

      entry: bundle://70.0:1/META-INF/services/org/apache/camel/TypeConverter in bundle org.apache.camel.camel-core

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/spring-event in bundle org.apache.camel.camel-spring

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/test in bundle org.apache.camel.camel-spring

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/validator in bundle org.apache.camel.camel-spring

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator    96 | Found

       

      entry: META-INF/services/org/apache/camel/component/xslt in bundle org.apache.camel.camel-spring

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator   121 | Found

       

      entry: bundle://72.0:1/META-INF/services/org/apache/camel/TypeConverter in bundle org.apache.camel.camel-spring

      09:13:09,159 | DEBUG | Thread-8         | Activator                        | org.apache.camel.osgi.Activator   179 | actived

       

      Here it looks like the correct packages are found.

       

      What do I need to do in order to find converters in other bundles than my own (the standard converters in camel-core and my custom converters in another bundle)? I have a META-INF/spring/beans.xml that instantiates a bean implementing InitilizingBean and DisposableBean. In the afterPropertiesSet() method I create the route and in the destroy() method I stop the route. The route itself works but no converters are found.

       

      If I run the same code outside of Servicemix (starting the route in a main() function) - everything works fine.

       

      /Bengt

        • 1. Re: No camel converters found in Servicemix 4.1
          davsclaus

          When running Camel in OSGi container such as FUSE ESB 4.x it needs to use OSGi aware class resolvers.

           

          And it looks like it uses the default ones, that are not OSGi aware.

           

          It should detect that it runs in OSGi and switch to use OSGi aware annotation converter package scanner.

           

          OSGi has been improved in the latest releases. For instance FUSE MR 1.6.1.0 has just been released yesterday. So you could upgrade your FUSE ESB to use that version.

          • 2. Re: No camel converters found in Servicemix 4.1
            rodehav

            Thanks for your rapid answer.

             

            I will certainly try FUSE MR 1.6.1.0. Do I just uninstall the previous version of camel (version 1.6.0.fuse  of camel-core, camel-osgi and camel-spring ) and install the new version of the same bundles or do I need to do anything else?

            • 3. Re: No camel converters found in Servicemix 4.1
              davsclaus

              No uninstall the old ones and install the new ones.

               

              A hard restart might help as well, but as its OSGi it should be able to do it on-the-fly.

              • 4. Re: No camel converters found in Servicemix 4.1
                njiang

                Hi,

                 

                Just two more questions about your issue:

                 

                1. How do you create the camel route ?

                  If you just use the DefaultCamelContext to do that , I'm afraid it can't find the converter from  the OSGi bundle in your route.

                 

                2. Did your camel route bundle import the package of fix converters? Did the fix converters package  be exported

                from the bundle?

                 

                Willem

                • 5. Re: No camel converters found in Servicemix 4.1
                  rodehav

                  I tried Camel version 1.6.1.0-fuse but go the same results. Still can't find any converters and still it says "Using only regular classloaders".

                  • 6. Re: No camel converters found in Servicemix 4.1
                    rodehav

                    Hello!

                     

                    2. The answer is "yes" to both questions.

                     

                    1. This sounds interesting. Yes - I create a new DefaultCamelContext in the afterPropertiesSet() method and then start it. I then stop it in the destroy() method. How come this doesn't work? What is the proper way to create the camel context?

                    • 7. Re: No camel converters found in Servicemix 4.1
                      davsclaus

                      The proper way is to use a spring application context XML file and define a  in there.

                       

                      Then Camel will be able to detect the OSGi environment and set itself up for that.

                       

                      If you create a Camel context manually with:

                      CamelContext context = new DefaultCamelContext()

                       

                      then you are 100% in charge of adapting to OSGi environment.

                      So this is not recommended. In Camel 1.x that could be hard as the pluggable API for resolvers is not exposed. In Camel 2.0 that is easier.

                       

                      So try using a spring xml file to get yourself started.

                      • 8. Re: No camel converters found in Servicemix 4.1
                        davsclaus

                        There is a tiny camel-osgi example here

                        https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-osgi/

                         

                        Its currently only source code at Apache with no wiki documentation.

                        But it shows how to use the spring xml file to do the camel context.

                         

                        The spring xml files is located in the META-INF/spring folder that OSGi container will be able to auto load.

                        • 9. Re: No camel converters found in Servicemix 4.1
                          rodehav

                          Thanks for the help. I now create a camel context in my spring beans file and inject it into my spring bean which then uses it to create the route. The converters are now found.

                           

                          However, I now have another problem. The camel-core bundle (bundle 71 in my configuration), cannot find my camel component (FixComponent). The log says:

                           

                          10:44:26,005 | DEBUG | Component@c54b3b | ResolverUtil                     | g.apache.camel.util.ResolverUtil  509 | Could not find class 'org/apache/camel/fix/FixComponent.class' in classloader: 71.0. Reason: java.lang.ClassNotFoundException: org.apache.camel.fix.FixComponent

                           

                          How does this work? I guess camel-core cannot statically declare that it imports a package it doesn't know about statically (org.apache.camel.fix) so something has to happen dynamically. What do I need to do in order for camel-core to find my custom camel component?

                           

                          I do export the package org.apache.camel.fix.* from the bundle containing the camel component. Note, however that this is not the same bundle containing the route. Could this be a problem?

                          • 10. Re: No camel converters found in Servicemix 4.1
                            davsclaus

                            Hi

                             

                            Just declare you component in the spring XML file. Camel will automatic lookup in the bean registry for components.

                             

                            Then you avoid the classpath scanning and OSGi "issues".

                             

                             

                             

                            • 11. Re: No camel converters found in Servicemix 4.1
                              rodehav

                              That did the trick. Thanks a lot for your help - I really appreciate it!