3 Replies Latest reply on May 27, 2011 8:18 PM by Freeman(Yue) Fang

    Camel FTP Router - ClassCastException

    Mohamed Ebrahim Newbie

      Hi,

       

      I am trying to setup a simple Fuse servicemix project and embed a camel router to poll a remote FTP folder.

       

       

       

       

      My files files are received by the bean feedResponder which has method handleMessage and the only argument to the method is org.apache.camel.component.file.GenericFile. I am seeing a ClassCastException here, though the received class is of same type org.apache.camel.component.file.GenericFile. I am not sure, if it's due to classloader messup by the server. Please help.

        • 1. Re: Camel FTP Router - ClassCastException
          Freeman(Yue) Fang Master

          Hi,

           

          You need post full stacktrace here, that would be more helpful.

           

          If you saw ClassCastException between same class, generally the error is from the object is loaded by different classloader, it depend on how you package your camel router in OSGi container, such as did you embed camel jars in your customer bundle?

          Without those detailed info we can't tell what's going wrong here.

           

          Freeman

          • 2. Re: Camel FTP Router - ClassCastException
            Mohamed Ebrahim Newbie

            Hi,

             

            Thanks for your reply. It definitely looks like a classloader issue. Yes, I am bundling all my custom jars including camel jars. If I don't include camel jars, then I get ClassDefNotfound at runtime. If I try to deploy my process in a normal servlet container, everything works as expected. Here is the full stacktrace in the OSGI env

             

            Caused by: [org.apache.camel.CamelExecutionException - Exception occurred during execution on the exchange: Exchange[424.xml]]

            org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[424.xml]

                 at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1155)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.builder.ExpressionBuilder$31.evaluate(ExpressionBuilder.java:809)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.impl.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.bean.MethodInfo$2.evaluate(MethodInfo.java:356)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.bean.MethodInfo.createMethodInvocation(MethodInfo.java:196)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:186)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:150)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:74)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:102)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:72)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:64)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:174)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.Pipeline.process(Pipeline.java:125)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:64)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:330)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:157)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:121)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:97)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0]

                 at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)[:1.6.0]

                 at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)[:1.6.0]

                 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)[:1.6.0]

                 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)[:1.6.0]

                 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)[:1.6.0]

                 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)[:1.6.0]

                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)[:1.6.0]

                 at java.lang.Thread.run(Thread.java:619)[:1.6.0]

            Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.apache.camel.component.file.remote.RemoteFile but has value: GenericFile[424.xml] of type: org.apache.camel.component.file.remote.RemoteFile on: 424.xml. Caused by: No type converter available to convert from type: org.apache.camel.component.file.remote.RemoteFile to the required type: org.apache.camel.component.file.remote.RemoteFile with value GenericFile[424.xml]. Exchange[424.xml]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.camel.component.file.remote.RemoteFile to the required type: org.apache.camel.component.file.remote.RemoteFile with value GenericFile[424.xml]]

                 at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:102)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.builder.ExpressionBuilder$31.evaluate(ExpressionBuilder.java:807)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 ... 47 more

            Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.component.file.remote.RemoteFile to the required type: org.apache.camel.component.file.remote.RemoteFile with value GenericFile[424.xml]

                 at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:143)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

                 at org.apache.camel.core.osgi.OsgiTypeConverter.mandatoryConvertTo(OsgiTypeConverter.java:102)[75:org.apache.camel.camel-spring:2.6.0.fuse-01-15]

                 at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100)[68:org.apache.camel.camel-core:2.6.0.fuse-01-15]

            • 3. Re: Camel FTP Router - ClassCastException
              Freeman(Yue) Fang Master

              Hi,

               

              That's the problem, your customer bundle shouldn't include camel jars.

              All necessary camel jars should be installed as bundle in OSGi container, your customer bundle should be able to just use it, this is how OSGi works.

              To avoid ClassDefNotfound

              You need ensure

              1. your customer bundle import the necessary camel package

              2. you already install necessary camel features which contain the related camel bundles, for example, if you need use camel-jms component, just do

              features:install camel-jms.

               

              Freeman