Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 92E0C1197C for ; Thu, 22 May 2014 15:35:08 +0000 (UTC) Received: (qmail 4189 invoked by uid 500); 22 May 2014 15:35:08 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 4146 invoked by uid 500); 22 May 2014 15:35:08 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 4138 invoked by uid 99); 22 May 2014 15:35:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 May 2014 15:35:08 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [64.18.0.139] (HELO exprod5og121.obsmtp.com) (64.18.0.139) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 22 May 2014 15:35:05 +0000 Received: from WPKFL-EXCH01.fullsail.com ([66.192.104.18]) by exprod5ob121.postini.com ([64.18.4.12]) with SMTP ID DSNKU34ZEJjKeL4YbpZU9Il5OPdHyWt7WaTN@postini.com; Thu, 22 May 2014 08:34:41 PDT Received: from WPKFL-EXCHMBX03.fullsail.com ([fe80::695c:65e:4a59:9142]) by WPKFL-EXCH01.fullsail.com ([fe80::956e:b82:1e9:6494%19]) with mapi id 14.03.0181.006; Thu, 22 May 2014 11:34:39 -0400 From: "Wilkerson, Daniel" To: "users@camel.apache.org" Subject: Re: org.apache.camel.TypeConversionException: Error during type conversion from type: org.apache.camel.component.file.GenericFile to the required type Thread-Topic: org.apache.camel.TypeConversionException: Error during type conversion from type: org.apache.camel.component.file.GenericFile to the required type Thread-Index: AQHPdc3PwGOVjNfaEkmPfNMoHc9cu5tM9OyA///GKQA= Date: Thu, 22 May 2014 15:34:39 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.105.252] Content-Type: text/plain; charset="Windows-1252" Content-ID: <36FE023837905F4381FA2E6C9160EC03@fullsail.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Thank you for the quick reply Claus. I sincerely appreciate it. I placed the ahead of the Smooks as you mentioned but get a strange error that I suspect is BOM characters at the beginning of the CSV file. Is there a quick, clever way to strip BOM characters in a route before passing along to the Smooks endpoint? aused by: org.xml.sax.SAXParseException: Content is not allowed in prolog. at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76) at=20 org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86) ... 28 more On 5/22/14 11:01 AM, "Claus Ibsen" wrote: >Hi > >Add a 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 > 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 =AD 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=8A? >> >> Thanks you all! >> Daniel >> >> >> Test Output: >> >> Message History >> >>=20 >>------------------------------------------------------------------------- >>-------------------------------------------------------------- >> >> RouteId ProcessorId Processor >> Elapsed (ms) >> >> [route1 ] [route1 ] >>[file://data_files/data?delay=3D360000&delete=3Dfalse&fileName=3Ddat] [ >>61] >> >> [route1 ] [to1 ] [smooks://smooks-config.xml >> ] [ 59] >> >> >> Exchange >> >>=20 >>------------------------------------------------------------------------- >>-------------------------------------------------------------- >> >> Exchange[ >> >> Id =20 >>ID-ada0481cdb71c7-fullsail-com-49652-1400704749961-0-4 >> >> ExchangePattern InOnly >> >> Headers =20 >>{breadcrumbId=3DID-ada0481cdb71c7-fullsail-com-49652-1400704749961-0-3, >>CamelFileAbsolute=3Dfalse, >>CamelFileAbsolutePath=3D/Users/dwilkerson/jbdevworkspace/fs-camel-bluepri= nt >>/data_files/data/dat.csv, CamelFileLastModified=3D1400704750000, >>CamelFileLength=3D6, CamelFileName=3Ddat.csv, CamelFileNameConsumed=3Ddat= .csv, >>CamelFileNameOnly=3Ddat.csv, CamelFileParent=3Ddata_files/data, >>CamelFilePath=3Ddata_files/data/dat.csv, CamelFileRelativePath=3Ddat.csv, >>CamelRedelivered=3Dfalse, CamelRedeliveryCounter=3D0, >>CamelSmooksExecutionContext=3D{interface >>org.apache.camel.Exchange=3DExchange[org.apache.camel.component.file.Gene= ri >>cFileMessage@5b2f9ee1]}} >> >> BodyType org.apache.camel.component.file.GenericFile >> >> Body [Body is file based: GenericFile[dat.csv]] >> >> ] >> >> >> Stacktrace >> >>=20 >>------------------------------------------------------------------------- >>-------------------------------------------------------------- >> >> 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=20 >>org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseT >>ypeConverterRegistry.java:130) >> >> at=20 >>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=20 >>org.milyn.smooks.camel.processor.SmooksProcessor.getSource(SmooksProcesso >>r.java:172) >> >> at=20 >>org.milyn.smooks.camel.processor.SmooksProcessor.process(SmooksProcessor. >>java:112) >> >> at=20 >>org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java >>:103) >> >> at=20 >>org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java: >>71) >> >> at=20 >>org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProce >>ssorBridge.process(AsyncProcessorConverterHelper.java:61) >> >> at=20 >>org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110) >> >> at=20 >>org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInte >>rceptor.java:163) >> >> at=20 >>org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryError >>Handler.java:398) >> >> at=20 >>org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalPr >>ocessor.java:191) >> >> at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) >> >> at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) >> >> at=20 >>org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalPr >>ocessor.java:191) >> >> at=20 >>org.apache.camel.component.file.GenericFileConsumer.processExchange(Gener >>icFileConsumer.java:401) >> >> at=20 >>org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericF >>ileConsumer.java:201) >> >> at=20 >>org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsu >>mer.java:165) >> >> at=20 >>org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.j >>ava:187) >> >> at=20 >>org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.jav >>a:114) >> >> at=20 >>java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) >> >> at=20 >>java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317 >>) >> >> at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) >> >> at=20 >>java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.acce >>ss$101(ScheduledThreadPoolExecutor.java:98) >> >> at=20 >>java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runP >>eriodic(ScheduledThreadPoolExecutor.java:180) >> >> at=20 >>java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run( >>ScheduledThreadPoolExecutor.java:204) >> >> at=20 >>java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor >>.java:895) >> >> at=20 >>java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.jav >>a: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=20 >>org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper >>.java:1363) >> >> at=20 >>org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1005) >> >> at=20 >>org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(Ins >>tanceMethodTypeConverter.java:78) >> >> at=20 >>org.apache.camel.component.file.GenericFileConverter.convertTo(GenericFil >>eConverter.java:97) >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> >> at=20 >>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java >>:39) >> >> at=20 >>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI >>mpl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:597) >> >> at=20 >>org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001) >> >> at=20 >>org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convert >>To(StaticMethodFallbackTypeConverter.java:62) >> >> at=20 >>org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Bas >>eTypeConverterRegistry.java:315) >> >> at=20 >>org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseT >>ypeConverterRegistry.java:113) >> >> ... 29 more >> >> Caused by: java.lang.AbstractMethodError: >>javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V >> >> at=20 >>org.apache.camel.converter.jaxp.XmlConverter.createDocumentBuilderFactory >>(XmlConverter.java:957) >> >> at=20 >>org.apache.camel.converter.jaxp.XmlConverter.getDocumentBuilderFactory(Xm >>lConverter.java:897) >> >> at=20 >>org.apache.camel.converter.jaxp.XmlConverter.createDocumentBuilder(XmlCon >>verter.java:968) >> >> at=20 >>org.apache.camel.converter.jaxp.XmlConverter.toDOMSource(XmlConverter.jav >>a:596) >> >> at=20 >>org.apache.camel.converter.jaxp.XmlConverter.toDOMSource(XmlConverter.jav >>a:604) >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> >> at=20 >>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java >>:39) >> >> at=20 >>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI >>mpl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:597) >> >> at=20 >>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 =3D 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: >> >> >> > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" >> xmlns:camel=3D"http://camel.apache.org/schema/blueprint" >> xsi:schemaLocation=3D" >> 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"> >> >> >class=3D"org.milyn.smooks.camel.dataformat.SmooksDataFormat"> >> >> >> >> >xmlns=3D"http://camel.apache.org/schema/blueprint"> >> >> >> >uri=3D"file:data_files/data?fileName=3Ddat.csv&delete=3Dfalse&del= ay=3D360 >>000" /> >> >> >> >> >> >> >> >> >> >> Smooks Config: >> >> >> > xmlns:csv=3D"http://www.milyn.org/xsd/smooks/csv-1.2.xsd" >> xmlns:jb=3D"http://www.milyn.org/xsd/smooks/javabean-1.3.xsd" >> xmlns:camel=3D"http://www.milyn.org/xsd/smooks/camel-1.4.xsd" >> xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" >> xsi:schemaLocation=3D"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"> >> >> >createOnElement=3D"#document"> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > > > >--=20 >Claus Ibsen >----------------- >Red Hat, Inc. >Email: cibsen@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/