Hi Looks like you got some classpath mixup.
Are you trying to run it in an OSGi container or not? If not you should NOT have the camel-osgi.jar or camel-spring-osgi.jar in the classpath. > WARN [main] (OsgiCamelContextHelper.java:78) - BundleContext not set, > cannot run in OSGI container On Tue, Apr 20, 2010 at 5:13 PM, Kevin Fightmaster <kfightmas...@gmail.com> wrote: > I have the following two tests running against my application. I'm looking > for help on why B is failing. > > > A: > public static void main1(String[] args) throws Exception { > CamelContext context = new DefaultCamelContext(); > ConnectionFactory connectionFactory = new > ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); > context.addRoutes(new RouteBuilder() { > public void configure() { > from("file://project_feedoutput/").to("file://copy/"); > } > }); > context.start(); > Thread.sleep(10000); > System.out.println("Completed."); > context.stop(); > } > > > B: > public static void main2(String[] args) throws Exception { > ApplicationContext ctx = new > ClassPathXmlApplicationContext("classpath*:twitterconsumer.xml"); > CamelContext context = (CamelContext) ctx.getBean("camel"); > context.start(); > Thread.sleep(10000); > System.out.println("Completed."); > context.stop(); > } > > > > A works and B throws the exception at the bottom of this post. A sets up the > route through java right on the test. B uses the Spring context file to > define the route. > > > SPRING CONTEXT FILE > <?xml version="1.0" encoding="UTF-8"?> > <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context=" > http://www.springframework.org/schema/context" > xmlns:camel="http://camel.apache.org/schema/spring" xmlns:broker=" > http://activemq.apache.org/schema/core" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd > http://www.springframework.org/schema/context > http://www.springframework.org/schema/context/spring-context-2.5.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd > http://activemq.apache.org/schema/core > http://activemq.apache.org/schema/core/activemq-core.xsd"> > <context:component-scan base-package="com.ngc.iaep.services" /> > > <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> > <route> > <from uri="file://project_feedoutput/"/> > <to uri="file://copy/"/> > </route> > </camelContext> > <!-- import resource="classpath:camelroutes.xml"/ --> > > <broker:broker useJmx="false" persistent="false" brokerName="localhost"> > <broker:transportConnectors> > <broker:transportConnector name="tcp" uri="tcp://localhost:61610" /> > </broker:transportConnectors> > </broker:broker> > > <bean id="jms" > class="org.apache.activemq.camel.component.ActiveMQComponent"> > <property name="brokerURL" value="tcp://localhost:61610" /> > </bean> > </beans> > > > > EXCEPTION: > INFO [main] (AbstractApplicationContext.java:411) - Refreshing > org.springframework.context.support.classpathxmlapplicationcont...@7b7072: > display name > [org.springframework.context.support.classpathxmlapplicationcont...@7b7072]; > startup date [Tue Apr 20 11:09:34 EDT 2010]; root of context hierarchy > INFO [main] (XmlBeanDefinitionReader.java:323) - Loading XML bean > definitions from URL > [file:/C:/Documents%20and%20Settings/s398255/My%20Documents/workspace/iaep/target/classes/twitterconsumer.xml] > INFO [main] (CamelNamespaceHandler.java:113) - > camel-osgi.jar/camel-spring-osgi.jar detected in classpath > INFO [main] (AbstractApplicationContext.java:426) - Bean factory for > application context > [org.springframework.context.support.classpathxmlapplicationcont...@7b7072]: > org.springframework.beans.factory.support.defaultlistablebeanfact...@16eb6bc > WARN [main] (OsgiCamelContextHelper.java:78) - BundleContext not set, > cannot run in OSGI container > INFO [main] (DefaultListableBeanFactory.java:414) - Pre-instantiating > singletons in > org.springframework.beans.factory.support.defaultlistablebeanfact...@16eb6bc: > defining beans > [twittercollector,twittertransformation,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,template,consumerTemplate,camel:beanPostProcessor,camel,org.apache.activemq.xbean.XBeanBrokerService#0,jms]; > root of factory hierarchy > INFO [main] (BrokerService.java:462) - Using Persistence Adapter: > MemoryPersistenceAdapter > INFO [main] (BrokerService.java:703) - ActiveMQ 5.3.1 JMS Message Broker > (localhost) is starting > INFO [main] (BrokerService.java:705) - For help or more information please > see: http://activemq.apache.org/ > INFO [main] (TransportServerThreadSupport.java:72) - Listening for > connections at: tcp://localhost:61610 > INFO [main] (TransportConnector.java:250) - Connector tcp Started > INFO [main] (BrokerService.java:502) - ActiveMQ JMS Message Broker > (localhost, ID:lmvad00082448-1708-1271776175839-0:0) started > INFO [main] (DefaultCamelContext.java:1017) - Apache Camel 2.2.0 > (CamelContext:camel) is starting > INFO [main] (DefaultCamelContext.java:1481) - JMX enabled. Using > DefaultManagedLifecycleStrategy. > INFO [main] (DefaultCamelContext.java:1007) - Started 1 routes > INFO [main] (DefaultCamelContext.java:1009) - Apache Camel 2.2.0 > (CamelContext:camel) started > INFO [main] (DefaultCamelContext.java:1007) - Started 1 routes > INFO [main] (DefaultCamelContext.java:1009) - Apache Camel 2.2.0 > (CamelContext:camel) started > ERROR [Camel thread 0: FileComponent] (Logger.java:248) - Failed delivery > for exchangeId: 81b06c38-d0fe-4ecc-9bfb-26eea3d543b2. Exhausted after > delivery attempt: 1 caught: > org.apache.camel.component.file.GenericFileOperationFailedException: Cannot > store file: copy\twitter_results.xml > org.apache.camel.component.file.GenericFileOperationFailedException: Cannot > store file: copy\twitter_results.xml > at > org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:211) > at > org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:195) > at > org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:126) > at > org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:57) > at > org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97) > at > org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95) > at > org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146) > at > org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94) > at > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82) > at > org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67) > at > org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53) > at > org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82) > at > org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93) > at > org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67) > at > org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:177) > at > org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:143) > at > org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88) > at > org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49) > at > org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228) > at > org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:66) > at > org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48) > at > org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67) > at > org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:258) > at > org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:137) > at > org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103) > at > org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:106) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) > at > java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) > at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) > at java.lang.Thread.run(Thread.java:619) > Caused by: org.apache.camel.InvalidPayloadException: No body available of > type: java.io.InputStream but has value: GenericFile[twitter_results.xml] of > type: org.apache.camel.component.file.GenericFile on: Message: > GenericFile[twitter_results.xml]. Caused by: No type converter available to > convert from type: org.apache.camel.component.file.GenericFile to the > required type: java.io.InputStream with value > GenericFile[twitter_results.xml]. Exchange[Message: > GenericFile[twitter_results.xml]]. Caused by: > [org.apache.camel.NoTypeConversionAvailableException - No type converter > available to convert from type: org.apache.camel.component.file.GenericFile > to the required type: java.io.InputStream with value > GenericFile[twitter_results.xml]] > at > org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:103) > at > org.apache.camel.util.ExchangeHelper.getMandatoryInBody(ExchangeHelper.java:116) > at > org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:203) > ... 34 more > Caused by: org.apache.camel.NoTypeConversionAvailableException: No type > converter available to convert from type: > org.apache.camel.component.file.GenericFile to the required type: > java.io.InputStream with value GenericFile[twitter_results.xml] > at > org.apache.camel.impl.converter.DefaultTypeConverter.mandatoryConvertTo(DefaultTypeConverter.java:123) > at > org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101) > ... 36 more > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus