Hi Add a <convertBodyTo type="String"/> before the smooks so the data is in a format that smooks can read.
On Thu, May 22, 2014 at 4:55 PM, Wilkerson, Daniel <dwilker...@fullsail.com> wrote: > Hi everyone. I working on a data integration prototype/proof-of-concept using > Camel 2.12, Fuse 7.1, Smooks 1.5.2, and ActiveMQ 5.9. I'm stuck currently in > a unit test I'm writing to test binding an CSV file read from the file system > using the file:// component and passed to smooks for transforming directly to > some MyBatis POJO's I've already coded previously. While running my unit test > (without any ActiveMQ being used yet) I get the output/stacktrace below. I am > stuck and not sure how to get this to work properly. I've been through the > smooks and camel documentation but am hitting a wall seeing what the issue > might be. > > I have spent some time rummaging through the component unit tests in the > camel source code base, but haven't been able to find ones that are similar > to what I'm doing – e.g. Using CamelBluprintTestSupport with similar > components fashioned using declarative XML/DSL. > > What I'm look for my unit test to do is confirm the binding has occurred by > dumping the contents of the bound POJO to verify it contains the records from > the CSV. If I can get that far success fully, then I can move on to using my > Queues, the mybatis:// component, and trying pushing into my demo postgres > database. I have, thankfully, been able to get a sample to work that > transforms the CSV to XML and been able to route that along, however, that's > not the use case I'm looking for. > > Any help getting unstuck would be greatly appreciated. I posted my output, > smooks config, unit test bean, and my blueprint.xml file. I have structured > this project using the Camel Blueprint Maven archetype. It's seems like it > trying to use SAX to parse the file despite the fact that I'm trying to bind > directly to a POJO…? > > Thanks you all! > Daniel > > > Test Output: > > Message History > > --------------------------------------------------------------------------------------------------------------------------------------- > > RouteId ProcessorId Processor > Elapsed (ms) > > [route1 ] [route1 ] > [file://data_files/data?delay=360000&delete=false&fileName=dat] [ 61] > > [route1 ] [to1 ] [smooks://smooks-config.xml > ] [ 59] > > > Exchange > > --------------------------------------------------------------------------------------------------------------------------------------- > > Exchange[ > > Id ID-ada0481cdb71c7-fullsail-com-49652-1400704749961-0-4 > > ExchangePattern InOnly > > Headers > {breadcrumbId=ID-ada0481cdb71c7-fullsail-com-49652-1400704749961-0-3, > CamelFileAbsolute=false, > CamelFileAbsolutePath=/Users/dwilkerson/jbdevworkspace/fs-camel-blueprint/data_files/data/dat.csv, > CamelFileLastModified=1400704750000, CamelFileLength=6, > CamelFileName=dat.csv, CamelFileNameConsumed=dat.csv, > CamelFileNameOnly=dat.csv, CamelFileParent=data_files/data, > CamelFilePath=data_files/data/dat.csv, CamelFileRelativePath=dat.csv, > CamelRedelivered=false, CamelRedeliveryCounter=0, > CamelSmooksExecutionContext={interface > org.apache.camel.Exchange=Exchange[org.apache.camel.component.file.GenericFileMessage@5b2f9ee1]}} > > BodyType org.apache.camel.component.file.GenericFile > > Body [Body is file based: GenericFile[dat.csv]] > > ] > > > Stacktrace > > --------------------------------------------------------------------------------------------------------------------------------------- > > org.apache.camel.TypeConversionException: Error during type conversion from > type: org.apache.camel.component.file.GenericFile to the required type: > javax.xml.transform.Source with value GenericFile[dat.csv] due > java.lang.AbstractMethodError: > javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V > > at > org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:130) > > at > org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:108) > > at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:72) > > at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:47) > > at > org.milyn.smooks.camel.processor.SmooksProcessor.getSource(SmooksProcessor.java:172) > > at > org.milyn.smooks.camel.processor.SmooksProcessor.process(SmooksProcessor.java:112) > > at > org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103) > > at > org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71) > > at > org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) > > at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110) > > at > org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163) > > at > org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) > > at > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) > > at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) > > at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) > > at > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) > > at > org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:401) > > at > org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:201) > > at > org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:165) > > at > org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187) > > at > org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114) > > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) > > 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:180) > > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204) > > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > > at java.lang.Thread.run(Thread.java:695) > > Caused by: org.apache.camel.RuntimeCamelException: > java.lang.AbstractMethodError: > javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V > > at > org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363) > > at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1005) > > at > org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78) > > at > org.apache.camel.component.file.GenericFileConverter.convertTo(GenericFileConverter.java:97) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001) > > at > org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:62) > > at > org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:315) > > at > org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:113) > > ... 29 more > > Caused by: java.lang.AbstractMethodError: > javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V > > at > org.apache.camel.converter.jaxp.XmlConverter.createDocumentBuilderFactory(XmlConverter.java:957) > > at > org.apache.camel.converter.jaxp.XmlConverter.getDocumentBuilderFactory(XmlConverter.java:897) > > at > org.apache.camel.converter.jaxp.XmlConverter.createDocumentBuilder(XmlConverter.java:968) > > at > org.apache.camel.converter.jaxp.XmlConverter.toDOMSource(XmlConverter.java:596) > > at > org.apache.camel.converter.jaxp.XmlConverter.toDOMSource(XmlConverter.java:604) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001) > > ... 39 more > > [data_files/dat] GenericFileOnCompletion DEBUG Done processing file: > GenericFile > > Unit Test Class: > public class RouteTest extends CamelBlueprintTestSupport { > > @Override > protected String getBlueprintDescriptor() { > return "/OSGI-INF/blueprint/blueprint.xml"; > } > > @Override > public void setUp() throws Exception{ > super.setUp(); > // send a message > template.sendBodyAndHeader("file:data_files/data", "Dat", > Exchange.FILE_NAME, "dat.csv"); > } > > @Test > public void testRoute() throws Exception { > // set mock expectations > MockEndpoint me = getMockEndpoint("mock:results"); > me.expectedBodiesReceivedInAnyOrder("Dat"); > > // assert mocks > assertMockEndpointsSatisfied(); > > // assert on the debugBefore/debugAfter methods below being called as > we've enabled the debugger > } > } > > Bluprint.xml: > > <?xml version="1.0" encoding="UTF-8"?> > <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:camel="http://camel.apache.org/schema/blueprint" > xsi:schemaLocation=" > http://www.osgi.org/xmlns/blueprint/v1.0.0 > http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd > http://camel.apache.org/schema/blueprint > http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> > > <bean id="smooks" class="org.milyn.smooks.camel.dataformat.SmooksDataFormat"> > <argument value="classpath:/smooks-config.xml" /> > </bean> > > <camelContext trace="true" id="blueprintContext" > xmlns="http://camel.apache.org/schema/blueprint"> > <route> > <from uri="direct:in"/> > <from > uri="file:data_files/data?fileName=dat.csv&delete=false&delay=360000" > /> > > <to uri="smooks://smooks-config.xml"/> > <to uri="mock:result"/> > </route> > > </camelContext> > </blueprint> > > > Smooks Config: > > <?xml version="1.0"?> > <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" > xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd" > xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.3.xsd" > xmlns:camel="http://www.milyn.org/xsd/smooks/camel-1.4.xsd" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.milyn.org/xsd/smooks-1.1.xsd > http://www.milyn.org/xsd/smooks-1.1.xsd > http://www.milyn.org/xsd/smooks/javabean-1.3.xsd > http://www.milyn.org/xsd/smooks/javabean-1.3.xsd > http://www.milyn.org/xsd/smooks/camel-1.4.xsd > http://www.milyn.org/xsd/smooks/camel-1.4.xsd"> > > <jb:bean beanId="datBean" class="com.mycompany.Dat" > createOnElement="#document"> > <!-- jb:value property="assetsCount" data=""/> > <jb:value property="blocker" data=""/> > <jb:value property="code" data="code"/--> > <jb:value property="creditHours" data="credit_hours"/> > <!-- jb:value property="ctBatchAction" data=""/--> > <jb:value property="description" data="description"/> > <!-- jb:value property="id" data=""/--> > <jb:value property="lmsTitle" data="title"/> > <!-- jb:value property="minimumBlockReleaseScore" data=""/--> > <jb:value property="sisCourseId" data="sis_course_id"/> > <jb:value property="sisGradeScaleId" data="sis_grade_scale_id"/> > <jb:value property="sisTitle" data="title"/> > <!-- jb:value property="viewable" data=""/--> > </jb:bean> > > <camel:route beanId="datBean"> > <camel:to endpoint="direct:in" /> > </camel:route> > </smooks-resource-list> -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/