You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Lars <la...@ergogroup.no> on 2012/02/14 07:33:49 UTC

Zipping the content of several files into one file

Hi,
I'm using Camel 2.9.0 and try to aggregate the content of xml-files in a
directory into a zip-file. When I try to open the zip it is unreadable.
Look at the route below to see if I done some stupid errors.
Or maybe it is a better way to do this.

	<route id="outGoingInvoiceRoute" routePolicyRef="outgoingPolicy">
			<from uri="{{file.inbox}}" />
			<convertBodyTo type="java.lang.String" />
			<bean ref="xmlValidation" method="validate" />
			<aggregate strategyRef="aggregatorStrategy"
				completionTimeout="3000" completionSize="5"
				aggregationRepositoryRef="invoiceRepo">
				<correlationExpression>
					<constant>true</constant>
				</correlationExpression>
				<wireTap uri="{{ftp.outbox.nozip}}" />
				<marshal>
					<zip></zip>
				</marshal>
				<setHeader headerName="CamelFileName">
					<simple>Invoice-${date:now:yyyyMMddHHmmssSSS}.zip</simple>
				</setHeader>
				<to uri="{{ftp.outbox.zipped}}" />
				<setHeader headerName="timestamp">
					<simple>${date:now:yyyy-MM-dd HH:mm:ss}</simple>
				</setHeader>
				<to uri="velocity:receiptMsg.vm" />
				<to uri="activemq:no.acme.SuccessQueue" />
			</aggregate>
                 </route>

*
I also get some NPE during execution like this:*
java.lang.NullPointerException
	at
org.apache.camel.util.IOHelper.copy(IOHelper.java:164)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.util.IOHelper.copy(IOHelper.java:160)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.impl.ZipDataFormat.marshal(ZipDataFormat.java:48)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:59)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.aggregate.AggregateProcessor$1.run(AggregateProcessor.java:402)[camel-core-2.9.0.jar:2.9.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source)[:1.6.0_30]
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)[:1.6.0_30]
	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.6.0_30]
	at
org.apache.camel.util.concurrent.SynchronousExecutorService.execute(SynchronousExecutorService.java:62)[camel-core-2.9.0.jar:2.9.0]
	at java.util.concurrent.AbstractExecutorService.submit(Unknown
Source)[:1.6.0_30]
	at
org.apache.camel.processor.aggregate.AggregateProcessor.onSubmitCompletion(AggregateProcessor.java:394)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.aggregate.AggregateProcessor.access$1000(AggregateProcessor.java:77)[camel-core-2.9.0.jar:2.9.0]
	at
org.apache.camel.processor.aggregate.AggregateProcessor$RecoverTask.run(AggregateProcessor.java:789)[camel-core-2.9.0.jar:2.9.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source)[:1.6.0_30]
	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown
Source)[:1.6.0_30]
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)[:1.6.0_30]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown
Source)[:1.6.0_30]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown
Source)[:1.6.0_30]
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
Source)[:1.6.0_30]
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)[:1.6.0_30]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)[:1.6.0_30]
	at java.lang.Thread.run(Unknown Source)[:1.6.0_30]


Thanks in advance!

Best regards

Lars Stuevold



--
View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5481638.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Zipping the content of several files into one file

Posted by Babak Vahdat <ba...@swissonline.ch>.
Done: http://svn.apache.org/viewvc?view=revision&revision=1243995

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5482800.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Zipping the content of several files into one file

Posted by Willem <wi...@gmail.com>.
+1 for the change.
It makes sense.

Willem

On Feb 14, 2012, at 8:43 PM, Babak Vahdat wrote:

> Willem
> 
> Shouldn't ZipDataFormat.marshal() method [1] better make use of
> TypeConverter's mandatoryConvertTo() method instead of convertTo() to
> avoid such NPE as an ugly side effect when the conversion fails.
> 
> This "manadatory conversion behaviour" is already available by it's
> unmarshal() method.
> 
> WDYT?
> 
> [1]
> https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java
> 
> Babak
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5482318.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Zipping the content of several files into one file

Posted by Babak Vahdat <ba...@swissonline.ch>.
Willem

Shouldn't ZipDataFormat.marshal() method [1] better make use of
TypeConverter's mandatoryConvertTo() method instead of convertTo() to
avoid such NPE as an ugly side effect when the conversion fails.

This "manadatory conversion behaviour" is already available by it's
unmarshal() method.

WDYT?

[1]
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5482318.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Zipping the content of several files into one file

Posted by Lars <la...@ergogroup.no>.
Of course, here it is.

public class OutgoingAggregationStrategy implements AggregationStrategy {
	/**
	 * Aggregates the messages.
	 * 
	 * @param oldExchange
	 *            the existing aggregated message. Is <tt>null</tt> the very
	 *            first time as there are no existing message.
	 * @param newExchange
	 *            the incoming message. This is never <tt>null</tt>.
	 * @return the aggregated message.
	 */

	public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
		// the first time there are no existing message and therefore
		// the oldExchange is null. In these cases we just return
		// the newExchange
		
		if (oldExchange == null) {
			String newBody = newExchange.getIn().getBody(String.class);
			newExchange.getOut().setBody(newBody);
			Map<String, Object> headers = newExchange.getIn().getHeaders();
			newExchange.getOut().setHeaders(headers);
			return newExchange;
		}
		
		if (newExchange == null) {
			return oldExchange;
		}

		// in this example we add their bodies
		String oldBody = oldExchange.getIn().getBody(String.class);
		String newBody = newExchange.getIn().getBody(String.class);

		// the body should be the two bodies added together
		String body = oldBody + System.getProperty("line.separator") + newBody;

		// update the existing message with the added body
		oldExchange.getIn().setBody(body);
		// and return it
		return oldExchange;
	}

}

Lars

--
View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5485873.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Zipping the content of several files into one file

Posted by Lars <la...@ergogroup.no>.
Hi,

Actually, in this case I want aggregate the content of several files into
one file.

Lars

--
View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5489043.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Zipping the content of several files into one file

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 15, 2012 at 9:25 AM, Willem <wi...@gmail.com> wrote:
> Hi,
>
> It looks like there are some short coming of the Zip data format which doesn't support to combine the files together.

Yes the zip data format does not support files per see. For that we
would need to improve the data format.
As you would need to use special file zip API from the JDK for that.
http://docs.oracle.com/javase/6/docs/api/

We should probably look into this. Contributions is of course welcome.



\> BTW, I'm still interesting about the agggregatorStrategy that you use.
> Can you show me the code ?
>
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog: http://willemjiang.blogspot.com (English)
>          http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang
> Weibo: willemjiang
>
> On Feb 15, 2012, at 3:30 PM, Lars wrote:
>
>> Hi,
>>
>> I have deleted much of the "crap" and converted to file endpoint ( see
>> below). However the produced zip-file is still unreadable. However, if I
>> convert to gzip marshalling the file is readable. What is wrong with the zip
>> marshalling?
>>
>>
>>       <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>>               <route streamCache="true">
>>                       <from uri="{{file.inbox}}" />
>>                       <aggregate strategyRef="aggregatorStrategy"
>>                               completionTimeout="5000" completionSize="5">
>>                               <correlationExpression>
>>                                       <constant>true</constant>
>>                               </correlationExpression>
>>                               <marshal>
>>                                       <zip></zip>
>>                               </marshal>
>>                               <setHeader headerName="CamelFileName">
>>                                       <simple>${file:name}.zip</simple>
>>                               </setHeader>
>>                               <to uri="{{file.outbox}}" />
>>                       </aggregate>
>>               </route>
>>       </camelContext>
>>
>> Best regards
>>
>> Lars Stuevold
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5485128.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Zipping the content of several files into one file

Posted by Willem <wi...@gmail.com>.
Hi,

It looks like there are some short coming of the Zip data format which doesn't support to combine the files together. 
BTW, I'm still interesting about the agggregatorStrategy that you use.
Can you show me the code ?

Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang

On Feb 15, 2012, at 3:30 PM, Lars wrote:

> Hi,
> 
> I have deleted much of the "crap" and converted to file endpoint ( see
> below). However the produced zip-file is still unreadable. However, if I
> convert to gzip marshalling the file is readable. What is wrong with the zip
> marshalling?
> 
> 
> 	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
> 		<route streamCache="true">
> 			<from uri="{{file.inbox}}" />
> 			<aggregate strategyRef="aggregatorStrategy"
> 				completionTimeout="5000" completionSize="5">
> 				<correlationExpression>
> 					<constant>true</constant>
> 				</correlationExpression>
> 				<marshal>
> 					<zip></zip>
> 				</marshal>
> 				<setHeader headerName="CamelFileName">
> 					<simple>${file:name}.zip</simple>
> 				</setHeader>
> 				<to uri="{{file.outbox}}" />
> 			</aggregate>
> 		</route>
> 	</camelContext>
> 
> Best regards 
> 
> Lars Stuevold
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5485128.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Zipping the content of several files into one file

Posted by Lars <la...@ergogroup.no>.
Hi,

I have deleted much of the "crap" and converted to file endpoint ( see
below). However the produced zip-file is still unreadable. However, if I
convert to gzip marshalling the file is readable. What is wrong with the zip
marshalling?


	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
		<route streamCache="true">
			<from uri="{{file.inbox}}" />
			<aggregate strategyRef="aggregatorStrategy"
				completionTimeout="5000" completionSize="5">
				<correlationExpression>
					<constant>true</constant>
				</correlationExpression>
				<marshal>
					<zip></zip>
				</marshal>
				<setHeader headerName="CamelFileName">
					<simple>${file:name}.zip</simple>
				</setHeader>
				<to uri="{{file.outbox}}" />
			</aggregate>
		</route>
	</camelContext>

Best regards 

Lars Stuevold

--
View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5485128.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Zipping the content of several files into one file

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Can you just change the ftp endpoint to a normal file endpoint ?
I'm not sure if the issue is related to it.

On Tue Feb 14 22:23:01 2012, Lars wrote:
> Thanks!
>
> By configuring stream cache I got rid of NPE.
> But the zip-file is still unreadable.
>
> Best regards
>
> Lars Stuevold
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5482567.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 


Re: Zipping the content of several files into one file

Posted by Lars <la...@ergogroup.no>.
Thanks!

By configuring stream cache I got rid of NPE.
But the zip-file is still unreadable.

Best regards 

Lars Stuevold

--
View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5482567.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Zipping the content of several files into one file

Posted by Willem Jiang <wi...@gmail.com>.
You need to enable the stream cache[1], as the stream is consumed when 
<wireTap uri="{{ftp.outbox.nozip}}" />.

[1]http://camel.apache.org/stream-caching.html

On Tue Feb 14 14:33:49 2012, Lars wrote:
> Hi,
> I'm using Camel 2.9.0 and try to aggregate the content of xml-files in a
> directory into a zip-file. When I try to open the zip it is unreadable.
> Look at the route below to see if I done some stupid errors.
> Or maybe it is a better way to do this.
>
> 	<route id="outGoingInvoiceRoute" routePolicyRef="outgoingPolicy">
> 			<from uri="{{file.inbox}}" />
> 			<convertBodyTo type="java.lang.String" />
> 			<bean ref="xmlValidation" method="validate" />
> 			<aggregate strategyRef="aggregatorStrategy"
> 				completionTimeout="3000" completionSize="5"
> 				aggregationRepositoryRef="invoiceRepo">
> 				<correlationExpression>
> 					<constant>true</constant>
> 				</correlationExpression>
> 				<wireTap uri="{{ftp.outbox.nozip}}" />
> 				<marshal>
> 					<zip></zip>
> 				</marshal>
> 				<setHeader headerName="CamelFileName">
> 					<simple>Invoice-${date:now:yyyyMMddHHmmssSSS}.zip</simple>
> 				</setHeader>
> 				<to uri="{{ftp.outbox.zipped}}" />
> 				<setHeader headerName="timestamp">
> 					<simple>${date:now:yyyy-MM-dd HH:mm:ss}</simple>
> 				</setHeader>
> 				<to uri="velocity:receiptMsg.vm" />
> 				<to uri="activemq:no.acme.SuccessQueue" />
> 			</aggregate>
>                   </route>
>
> *
> I also get some NPE during execution like this:*
> java.lang.NullPointerException
> 	at
> org.apache.camel.util.IOHelper.copy(IOHelper.java:164)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.util.IOHelper.copy(IOHelper.java:160)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.impl.ZipDataFormat.marshal(ZipDataFormat.java:48)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:59)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.aggregate.AggregateProcessor$1.run(AggregateProcessor.java:402)[camel-core-2.9.0.jar:2.9.0]
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
> Source)[:1.6.0_30]
> 	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)[:1.6.0_30]
> 	at java.util.concurrent.FutureTask.run(Unknown Source)[:1.6.0_30]
> 	at
> org.apache.camel.util.concurrent.SynchronousExecutorService.execute(SynchronousExecutorService.java:62)[camel-core-2.9.0.jar:2.9.0]
> 	at java.util.concurrent.AbstractExecutorService.submit(Unknown
> Source)[:1.6.0_30]
> 	at
> org.apache.camel.processor.aggregate.AggregateProcessor.onSubmitCompletion(AggregateProcessor.java:394)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.aggregate.AggregateProcessor.access$1000(AggregateProcessor.java:77)[camel-core-2.9.0.jar:2.9.0]
> 	at
> org.apache.camel.processor.aggregate.AggregateProcessor$RecoverTask.run(AggregateProcessor.java:789)[camel-core-2.9.0.jar:2.9.0]
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
> Source)[:1.6.0_30]
> 	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown
> Source)[:1.6.0_30]
> 	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)[:1.6.0_30]
> 	at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown
> Source)[:1.6.0_30]
> 	at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown
> Source)[:1.6.0_30]
> 	at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
> Source)[:1.6.0_30]
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)[:1.6.0_30]
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)[:1.6.0_30]
> 	at java.lang.Thread.run(Unknown Source)[:1.6.0_30]
>
>
> Thanks in advance!
>
> Best regards
>
> Lars Stuevold
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5481638.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 


Re: Zipping the content of several files into one file

Posted by Vincent Nonnenmacher <vi...@gmail.com>.
Never used the zip data format
But weren't you supposed to write something like

<marshall ref="yourzipdataformatbean" /> ?
Where your bean coud be specified with the proper deflation setting.

But it sound from your stack trace that a ZipDataFormat is called by the
Marshall.process
What did say IOHelper at line 164 called from copy method ?

On Tuesday, February 14, 2012, Lars <la...@ergogroup.no> wrote:
> Hi,
> I'm using Camel 2.9.0 and try to aggregate the content of xml-files in a
> directory into a zip-file. When I try to open the zip it is unreadable.
> Look at the route below to see if I done some stupid errors.
> Or maybe it is a better way to do this.
>
>        <route id="outGoingInvoiceRoute" routePolicyRef="outgoingPolicy">
>                        <from uri="{{file.inbox}}" />
>                        <convertBodyTo type="java.lang.String" />
>                        <bean ref="xmlValidation" method="validate" />
>                        <aggregate strategyRef="aggregatorStrategy"
>                                completionTimeout="3000" completionSize="5"
>                                aggregationRepositoryRef="invoiceRepo">
>                                <correlationExpression>
>                                        <constant>true</constant>
>                                </correlationExpression>
>                                <wireTap uri="{{ftp.outbox.nozip}}" />
>                                <marshal>
>                                        <zip></zip>
>                                </marshal>
>                                <setHeader headerName="CamelFileName">
>
 <simple>Invoice-${date:now:yyyyMMddHHmmssSSS}.zip</simple>
>                                </setHeader>
>                                <to uri="{{ftp.outbox.zipped}}" />
>                                <setHeader headerName="timestamp">
>                                        <simple>${date:now:yyyy-MM-dd
HH:mm:ss}</simple>
>                                </setHeader>
>                                <to uri="velocity:receiptMsg.vm" />
>                                <to uri="activemq:no.acme.SuccessQueue" />
>                        </aggregate>
>                 </route>
>
> *
> I also get some NPE during execution like this:*
> java.lang.NullPointerException
>        at
>
org.apache.camel.util.IOHelper.copy(IOHelper.java:164)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.util.IOHelper.copy(IOHelper.java:160)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.impl.ZipDataFormat.marshal(ZipDataFormat.java:48)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:59)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.aggregate.AggregateProcessor$1.run(AggregateProcessor.java:402)[camel-core-2.9.0.jar:2.9.0]
>        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
> Source)[:1.6.0_30]
>        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown
Source)[:1.6.0_30]
>        at java.util.concurrent.FutureTask.run(Unknown Source)[:1.6.0_30]
>        at
>
org.apache.camel.util.concurrent.SynchronousExecutorService.execute(SynchronousExecutorService.java:62)[camel-core-2.9.0.jar:2.9.0]
>        at java.util.concurrent.AbstractExecutorService.submit(Unknown
> Source)[:1.6.0_30]
>        at
>
org.apache.camel.processor.aggregate.AggregateProcessor.onSubmitCompletion(AggregateProcessor.java:394)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.aggregate.AggregateProcessor.access$1000(AggregateProcessor.java:77)[camel-core-2.9.0.jar:2.9.0]
>        at
>
org.apache.camel.processor.aggregate.AggregateProcessor$RecoverTask.run(AggregateProcessor.java:789)[camel-core-2.9.0.jar:2.9.0]
>        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
> Source)[:1.6.0_30]
>        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown
> Source)[:1.6.0_30]
>        at java.util.concurrent.FutureTask.runAndReset(Unknown
Source)[:1.6.0_30]
>        at
>
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown
> Source)[:1.6.0_30]
>        at
>
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown
> Source)[:1.6.0_30]
>        at
>
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
> Source)[:1.6.0_30]
>        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
> Source)[:1.6.0_30]
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)[:1.6.0_30]
>        at java.lang.Thread.run(Unknown Source)[:1.6.0_30]
>
>
> Thanks in advance!
>
> Best regards
>
> Lars Stuevold
>
>
>
> --
> View this message in context:
http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5481638.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>