Re: content-enrich

2009-03-03 Thread Martin Krasser
... just updated the enricher documentation with an example aggregation 
strategy.


Martin

Peter Maas schrieb:


On Mar 3, 2009, at 8:10 , Claus Ibsen wrote:


On Tue, Mar 3, 2009 at 7:56 AM, Peter Maas pfmm...@gmail.com wrote:
I think you've solved my problem. I was looking at the 'in' message 
of the
resource exchange, whereas I should be looking at the 'out' message. 
And,
btw, yes the CinemaQueryAssembler is thread-safe, I actually think 
all code

should be threadsafe ;)

Yeah if we could just got some basic annotations in the JDK, eg
@ThreadSafe then you could document it like that :)

Maybe we need to improve the wiki for using the enricher to state you
should check the OUT for the response.
http://camel.apache.org/content-enricher.html


Yeah, I actually think the documentation of the content-enricher is 
quite sparse, a simple example AggregationStrategy might help a lot:



public class ProgramMerger implements AggregationStrategy {

public Exchange aggregate(Exchange original, Exchange resource) {

Document org = original.getIn().getBody(Document.class);
Document additional = resource.getOut().getBody(Document.class);

   
// create the new 'enriched' message

Document result = ...;
original.getOut().setBody(result);
   
return original;

}

}





On Tue, Mar 3, 2009 at 7:02 AM, Martin Krasser 
d...@martin-krasser.dewrote:



Hi Peter,

the route looks good to me.

* The in-messages of the original exchange and the resource 
exchange are
always identical. The out-message of the resource exchange will 
contain the

result from 'direct:enrichMovie'.
* What message exchange pattern do you use when you test (print the
contents of) the 'direct:enrichMovie' route?
* Is the CinemaQueryAssembler thread-safe? You're doing parallel 
processing

of split messages.

Martin

Peter Maas schrieb:

 Hi list,


I'm developing a proof-of-concept application using Camel 2.0. 
Everything

seems to work just find... except for the content-enricher. Both the
resource exchange passed to my AggregationStrategy look identical. 
Whilst if
I print the contents of the resource route I the the correct xml 
in the

exchange after calling the http service. My routes look like this:

   // split messages when received from the incoming mq
   // enrich if move. Always stor in database
   from(activemq:topic:incomingVPROGuide)
   
.split(vpro.xpath(//vpro:program)).parallelProcessing(true)

   .choice()
   .when(vpro.xpath(/vpro:progr...@ismovie = 'true']))
   .enrich(direct:enrichMovie, new ProgramMerger())
   .to(direct:save)
   .otherwise().to(direct:save);
   // the generic save route
   from(direct:save)
   .setHeader(xmldb.resource.name,
vpro.xpath(//vpro:program/@id, String.class))
   .process(sanitize(xmldb.resource.name))
   .to(xmldb:/programs);
 // route to retrieve data from external
   // rest service
   from(direct:enrichMovie)
   .setHeader(title,
vpro.xpath(/vpro:program/vpro:title[1]/text(), String.class))
   .setHeader(director, vpro.xpath(//vpro:pers...@urn =
'urn:mpeg:mpeg7:cs:RoleCS:2001:DIRECTOR' and 
1]/vpro:familyName/text(),

String.class))
   .setHeader(year, vpro.xpath(//vpro:year[1]/text(),
String.class))
   .process(new CinemaQueryAssembler())
   
.to(http://cinema.test.vpro.nl/api/1/rest/movie/find.xml;);


The xmldb producer is a patched version of the camel-extra project.
Everything works fine, apart from the enricher...

Any hints?

kind regards,

Peter Maas










--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/







Re: Camel 2.0-snapshot deployed on SMKNL4 - There are 2 parameters that couldn't be set on the endpoint

2009-03-03 Thread cmoulliard

OK. By the way it works fine with absolute paths.


Claus Ibsen-2 wrote:
 
 The problem is that you mix and match absolute with relative.
 
 I will add a fix but you should also use absolute paths for the move
 expression as a workaround.
 
 
 On Tue, Mar 3, 2009 at 10:16 AM, cmoulliard cmoulli...@gmail.com wrote:

 Hi claus,

 I receive the following error :

 2009-03-03 10:09:41,859 ERROR FileConsumer -
 java.lang.NullPointerException
        at
 org.apache.camel.component.file.GenericFile.changeFileName(GenericFile.java:119)
        at
 org.apache.camel.component.file.strategy.GenericFileExpressionRenamer.renameFile(GenericFileExpressionRenamer.java:41)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:57)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
        at
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
        at
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        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)

 with the following configuration :

 from uri=file://d:/temp/data/?moveExpression=../done/${file:name} /

 Any idea ?

 Regards,


 Claus Ibsen-2 wrote:

 Hi

 The option for file have changed in camel 2.0. See:
 http://camel.apache.org/file2.html

 All the pre/postfix etc. is based on expressions now. So it should be
 something like this:
 moveExpression=../done/${file:name}
 preMoveExpression=inprogress/${file:name}



 On Mon, Mar 2, 2009 at 5:40 PM, cmoulliard cmoulli...@gmail.com wrote:

 Hi,

 The following error is reported when I deploy a camel project on
 Service
 Mix
 Kernel 1.1.0 snashot where Camel-2.0 SNAPSHOT osgi bundle is deployed ?

 17:36:17,640 | ERROR | xtenderThread-15 |
 OsgiBundleXmlApplicationContext
  |
 gatedExecutionApplicationContext  366 | Post refresh error
 org.apache.camel.ResolveEndpointFailedException: Failed to resolve
 endpoint:
 file://d:/temp/data/?preMoveNamePrefix=inprogress/moveNamePrefix=../done/
 due to: org.apache.camel.ResolveEndpointFailedException: Failed to
 resolve
 endpoint:
 file://d:/temp/data/?preMoveNamePrefix=inprogress/moveNamePrefix=../done/
 due to: There are 2 parameters that couldn't be set on the endpoint.
 Check
 the uri if the parameters are spelt correctly and that they are
 properties
 of the endpoint. Unknown parameters=[{moveNamePrefix=../done/,
 preMoveNamePrefix=inprogress/}]
        at
 org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:356)
        at
 org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:55)
        at
 org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:133)
        at
 org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:103)
        at
 org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:109)
        at
 org.apache.camel.model.FromType.resolveEndpoint(FromType.java:72)
        at
 org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:78)
        at
 org.apache.camel.model.RouteType.addRoutes(RouteType.java:302)
    

Re: Camel 2.0-snapshot deployed on SMKNL4 - There are 2 parameters that couldn't be set on the endpoint

2009-03-03 Thread cmoulliard

I don't if this point must be fixed or not but when a file already exist in
the 'done' directory, then the following error is generated :

2009-03-03 10:34:00,937 ERROR FileConsumer - Cannot rename file:
GenericFile[d:\temp\data\csv.txt] to: GenericFile[d:\temp\done\csv.txt] 
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
rename file: GenericFile[d:\temp\data\csv.txt] to:
GenericFile[d:\temp\done\csv.txt]
at
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:82)
at
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:58)
at
org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
at
org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
at
org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
at
org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
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)




cmoulliard wrote:
 
 OK. By the way it works fine with absolute paths.
 
 
 Claus Ibsen-2 wrote:
 
 The problem is that you mix and match absolute with relative.
 
 I will add a fix but you should also use absolute paths for the move
 expression as a workaround.
 
 
 On Tue, Mar 3, 2009 at 10:16 AM, cmoulliard cmoulli...@gmail.com wrote:

 Hi claus,

 I receive the following error :

 2009-03-03 10:09:41,859 ERROR FileConsumer -
 java.lang.NullPointerException
        at
 org.apache.camel.component.file.GenericFile.changeFileName(GenericFile.java:119)
        at
 org.apache.camel.component.file.strategy.GenericFileExpressionRenamer.renameFile(GenericFileExpressionRenamer.java:41)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:57)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
        at
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
        at
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        at
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at
 

Re: Camel 2.0-snapshot deployed on SMKNL4 - There are 2 parameters that couldn't be set on the endpoint

2009-03-03 Thread Claus Ibsen
It is trying to delete the file first. Are you sure its not locked or
something by another app.

Could you try again and be sure the existing file is not open by some
other apps.


On Tue, Mar 3, 2009 at 10:36 AM, cmoulliard cmoulli...@gmail.com wrote:

 I don't if this point must be fixed or not but when a file already exist in
 the 'done' directory, then the following error is generated :

 2009-03-03 10:34:00,937 ERROR FileConsumer - Cannot rename file:
 GenericFile[d:\temp\data\csv.txt] to: GenericFile[d:\temp\done\csv.txt]
 org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
 rename file: GenericFile[d:\temp\data\csv.txt] to:
 GenericFile[d:\temp\done\csv.txt]
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:82)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:58)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
        at
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
        at
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        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)




 cmoulliard wrote:

 OK. By the way it works fine with absolute paths.


 Claus Ibsen-2 wrote:

 The problem is that you mix and match absolute with relative.

 I will add a fix but you should also use absolute paths for the move
 expression as a workaround.


 On Tue, Mar 3, 2009 at 10:16 AM, cmoulliard cmoulli...@gmail.com wrote:

 Hi claus,

 I receive the following error :

 2009-03-03 10:09:41,859 ERROR FileConsumer -
 java.lang.NullPointerException
        at
 org.apache.camel.component.file.GenericFile.changeFileName(GenericFile.java:119)
        at
 org.apache.camel.component.file.strategy.GenericFileExpressionRenamer.renameFile(GenericFileExpressionRenamer.java:41)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:57)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
        at
 

Re: StreamCaching in Camel 1.6

2009-03-03 Thread Gert Vanthienen
Jens,

Stream caching is turned on automatically when you use a
DeadLetterChannel as the error handler.  Because the Exchange might be
redelivered or sent to the DLQ destination, we have to cache it before
we send it into the DLC.  Adding an errorHandler(noErrorHandler()); to
the configure() method should fix that for you.

Regards,

Gert Vanthienen

Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/3/3 _Jens jens.riemschnei...@icw.de:

 Hi,

 I have run into a problem with stream caching in Camel 1.6. I have a route
 that reads data via streaming from an Http request. In some cases this can
 be a large amount of data, so I cannot stream the data completely into
 memory. I wrote this little test to demonstrate my problem:

   �...@test
    public void testUploadFailsForHugeFile() throws Exception {
        CamelContext context = new DefaultCamelContext();

        context.addRoutes(new RouteBuilder() {
           �...@override
            public void configure() throws Exception {
                noStreamCaching();
                from(jetty:http://localhost:8989/bigfile;)
                    .noStreamCaching()
                    .process(new Processor() {
                        public void process(Exchange exchange) throws
 Exception {
                            InputStream inputStream =
 exchange.getIn().getBody(InputStream.class);
                            while (inputStream.read() != -1) {}
                        }
                    });
            }
        });

        context.start();

        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod(http://localhost:8989/bigfile;);
        File file = new File(c:\\temp\\test.bin.ok2);
        method.setRequestEntity(new FileRequestEntity(file,
 unknown/unknown));
        assertEquals(200, client.executeMethod(method));
    }

 This fails with an OutOfMemoryError if test.bin.ok2 is a larger file because
 the StreamCachingInterceptor reads the input stream into memory. Now I
 understand that stream caching is turned on by default in Camel 1.6.
 However, as you can see I tried to disable it in the route builder. This
 seems not to make any difference.

 Now, my question is if there is some other way to disable stream caching or
 if I'm doing something wrong here.

 Thanks in advance
 Jens
 --
 View this message in context: 
 http://www.nabble.com/StreamCaching-in-Camel-1.6-tp22305654p22305654.html
 Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.




Re: Classloading and OSGI

2009-03-03 Thread willem.jiang

I just want to ask a question, did your bundle has the import of
org.apache.camel.component.jms.* ?

If so, the ObjectHelper should be able to load the default
QueueBrowserStrategy.

Willem


willem.jiang wrote:
 
 Hi ,  
 
 I just created a JIRA[1] for your issue.
 And will commit a quick fix for it.
 If you have time please check out the latest camel 2.0 snapshot to verify
 it.
 
 [1] https://issues.apache.org/activemq/browse/CAMEL-1412
 
 Willem
 
 
 atlep wrote:
 
 I am using camel in  a OSGI (Felix) environment, and I regularly bump
 into classloading issues:
 
 THe most recentones are
 The JSM Component cant find the QueueBrowserStrategy because it cannot
 see the spring bundle that exports it, because it is using a wrong 
 classloader to try to load it (it uses o.a.c.util.ObjectHelper's
 classloader).
 
 The activemq component cannot load object messages because it cannot
 deserialize the body. I have tried setting the thread contextclassloader
 to my bundles classloader, but it seems it does not use the context
 classloader.
 
 Are there any good practices or patterns regarding using camel + activemq
 in a OSGi environment, without resorting to servicemix? 
 
 Maybe these wrinkles are ironed out in camel 2.0?
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Classloading-and-OSGI-tp22303475p22305791.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.



Re: Camel 2.0-snapshot deployed on SMKNL4 - There are 2 parameters that couldn't be set on the endpoint

2009-03-03 Thread cmoulliard

You are right ;-) The file was locked by another application.


Claus Ibsen-2 wrote:
 
 It is trying to delete the file first. Are you sure its not locked or
 something by another app.
 
 Could you try again and be sure the existing file is not open by some
 other apps.
 
 
 On Tue, Mar 3, 2009 at 10:36 AM, cmoulliard cmoulli...@gmail.com wrote:

 I don't if this point must be fixed or not but when a file already exist
 in
 the 'done' directory, then the following error is generated :

 2009-03-03 10:34:00,937 ERROR FileConsumer - Cannot rename file:
 GenericFile[d:\temp\data\csv.txt] to: GenericFile[d:\temp\done\csv.txt]
 org.apache.camel.component.file.GenericFileOperationFailedException:
 Cannot
 rename file: GenericFile[d:\temp\data\csv.txt] to:
 GenericFile[d:\temp\done\csv.txt]
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:82)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:58)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
        at
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
        at
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        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)




 cmoulliard wrote:

 OK. By the way it works fine with absolute paths.


 Claus Ibsen-2 wrote:

 The problem is that you mix and match absolute with relative.

 I will add a fix but you should also use absolute paths for the move
 expression as a workaround.


 On Tue, Mar 3, 2009 at 10:16 AM, cmoulliard cmoulli...@gmail.com
 wrote:

 Hi claus,

 I receive the following error :

 2009-03-03 10:09:41,859 ERROR FileConsumer -
 java.lang.NullPointerException
        at
 org.apache.camel.component.file.GenericFile.changeFileName(GenericFile.java:119)
        at
 org.apache.camel.component.file.strategy.GenericFileExpressionRenamer.renameFile(GenericFileExpressionRenamer.java:41)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:57)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at
 org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 

Re: Camel 2.0-snapshot deployed on SMKNL4 - There are 2 parameters that couldn't be set on the endpoint

2009-03-03 Thread Claus Ibsen
Hi

Are you by any chance running on Windows platform? I am just curious
as we have got a report on windows with 1.x sometimes can not move
file after processing.


On Tue, Mar 3, 2009 at 11:31 AM, cmoulliard cmoulli...@gmail.com wrote:

 You are right ;-) The file was locked by another application.


 Claus Ibsen-2 wrote:

 It is trying to delete the file first. Are you sure its not locked or
 something by another app.

 Could you try again and be sure the existing file is not open by some
 other apps.


 On Tue, Mar 3, 2009 at 10:36 AM, cmoulliard cmoulli...@gmail.com wrote:

 I don't if this point must be fixed or not but when a file already exist
 in
 the 'done' directory, then the following error is generated :

 2009-03-03 10:34:00,937 ERROR FileConsumer - Cannot rename file:
 GenericFile[d:\temp\data\csv.txt] to: GenericFile[d:\temp\done\csv.txt]
 org.apache.camel.component.file.GenericFileOperationFailedException:
 Cannot
 rename file: GenericFile[d:\temp\data\csv.txt] to:
 GenericFile[d:\temp\done\csv.txt]
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.renameFile(GenericFileRenameProcessStrategy.java:82)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:58)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
        at
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
        at
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        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)




 cmoulliard wrote:

 OK. By the way it works fine with absolute paths.


 Claus Ibsen-2 wrote:

 The problem is that you mix and match absolute with relative.

 I will add a fix but you should also use absolute paths for the move
 expression as a workaround.


 On Tue, Mar 3, 2009 at 10:16 AM, cmoulliard cmoulli...@gmail.com
 wrote:

 Hi claus,

 I receive the following error :

 2009-03-03 10:09:41,859 ERROR FileConsumer -
 java.lang.NullPointerException
        at
 org.apache.camel.component.file.GenericFile.changeFileName(GenericFile.java:119)
        at
 org.apache.camel.component.file.strategy.GenericFileExpressionRenamer.renameFile(GenericFileExpressionRenamer.java:41)
        at
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.commit(GenericFileRenameProcessStrategy.java:57)
        at
 org.apache.camel.component.file.GenericFileConsumer.processStrategyCommit(GenericFileConsumer.java:231)
        at
 org.apache.camel.component.file.GenericFileConsumer$1.done(GenericFileConsumer.java:185)
        at
 org.apache.camel.processor.UnitOfWorkProcessor$1.done(UnitOfWorkProcessor.java:57)
        at
 org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:74)
        at
 org.apache.camel.processor.Pipeline.process(Pipeline.java:106)
        at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
        at
 

Re: StreamCaching in Camel 1.6

2009-03-03 Thread willem.jiang

Hi 

Just as Gert said.
In CXF , we will cache the big message into the File instead of the memory.
I think we could do the same thing in Camel.
I just filled a JIRA[2] for it.

[1] http://www.nabble.com/Re%3A-StreamCaching-in-Camel-1.6-to22305858.html
[2] https://issues.apache.org/activemq/browse/CAMEL-1413

Willem


_Jens wrote:
 
 Hi,
 
 I have run into a problem with stream caching in Camel 1.6. I have a route
 that reads data via streaming from an Http request. In some cases this can
 be a large amount of data, so I cannot stream the data completely into
 memory. I wrote this little test to demonstrate my problem:
 
 @Test
 public void testUploadFailsForHugeFile() throws Exception {
 CamelContext context = new DefaultCamelContext();
 
 context.addRoutes(new RouteBuilder() {
 @Override
 public void configure() throws Exception {
 noStreamCaching();
 from(jetty:http://localhost:8989/bigfile;)
 .noStreamCaching()
 .process(new Processor() {
 public void process(Exchange exchange) throws
 Exception {
 InputStream inputStream =
 exchange.getIn().getBody(InputStream.class);
 while (inputStream.read() != -1) {}
 }
 });
 }
 });
 
 context.start();
 
 HttpClient client = new HttpClient();
 PostMethod method = new
 PostMethod(http://localhost:8989/bigfile;);
 File file = new File(c:\\temp\\test.bin.ok2);
 method.setRequestEntity(new FileRequestEntity(file,
 unknown/unknown));
 assertEquals(200, client.executeMethod(method));
 }
 
 This fails with an OutOfMemoryError if test.bin.ok2 is a larger file
 because the StreamCachingInterceptor reads the input stream into memory.
 Now I understand that stream caching is turned on by default in Camel 1.6.
 However, as you can see I tried to disable it in the route builder. This
 seems not to make any difference.
 
 Now, my question is if there is some other way to disable stream caching
 or if I'm doing something wrong here.
 
 Thanks in advance
 Jens
 

-- 
View this message in context: 
http://www.nabble.com/StreamCaching-in-Camel-1.6-tp22305654p22306407.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.



Re: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.component.file.GenericFileMessage to the required type - SMX4 !

2009-03-03 Thread cmoulliard

Hi,

Two remarks concerning what you propose :

1) If i try to use the camel context as you propose (using osgi schema),
camel cannot run localy (outside of a OSGI server)

[INFO] Classpath =
[file:/D:/Dvlpt/Java/workspace-ganymede/osgi/reportincident.interfaces/target/classes/,
file:/c:/.m2/repository/org/apache/camel/camel-core/2.0-SNAPSHOT/camel-core-2.0-SNAPSHOT.jar,
file:/c:/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar,
file:/c:/.m2/repository/org/apache/camel/camel-spring/2.0-SNAPSHOT/camel-spring-2.0-SNAPSHOT.jar,
file:/c:/.m2/repository/org/springframework/spring-core/2.5.6/spring-core-2.5.6.jar,
file:/c:/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar,
file:/c:/.m2/repository/org/springframework/spring-context/2.5.6/spring-context-2.5.6.jar,
file:/c:/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar,
file:/c:/.m2/repository/org/springframework/spring-beans/2.5.6/spring-beans-2.5.6.jar,
file:/c:/.m2/repository/org/springframework/spring-tx/2.5.6/spring-tx-2.5.6.jar,
file:/c:/.m2/repository/org/springframework/spring-aop/2.5.6/spring-aop-2.5.6.jar,
file:/c:/.m2/repository/org/apache/camel/camel-bindy/2.0-SNAPSHOT/camel-bindy-2.0-SNAPSHOT.jar,
file:/c:/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar]
2009-03-03 12:00:09,937 INFO  MainSupport - Apache Camel 2.0-SNAPSHOT
starting 
2009-03-03 12:00:09,984 INFO  ClassPathXmlApplicationContext - Refreshing
org.springframework.context.support.classpathxmlapplicationcont...@57ea52:
display name
[org.springframework.context.support.classpathxmlapplicationcont...@57ea52];
startup date [Tue Mar 03 12:00:09 CET 2009]; root of context hierarchy 
2009-03-03 12:00:10,109 DEBUG PathMatchingResourcePatternResolver - Looking
for matching resources in directory tree
[D:\Dvlpt\Java\workspace-ganymede\osgi\reportincident.interfaces\target\classes\META-INF\spring]
 
2009-03-03 12:00:10,109 DEBUG PathMatchingResourcePatternResolver -
Searching directory
[D:\Dvlpt\Java\workspace-ganymede\osgi\reportincident.interfaces\target\classes\META-INF\spring]
for files matching pattern
[D:/Dvlpt/Java/workspace-ganymede/osgi/reportincident.interfaces/target/classes/META-INF/spring/*.xml]
 
2009-03-03 12:00:10,125 DEBUG PathMatchingResourcePatternResolver - Resolved
location pattern [META-INF/spring/*.xml] to resources [file
[D:\Dvlpt\Java\workspace-ganymede\osgi\reportincident.interfaces\target\classes\META-INF\spring\camel-context.xml]]
 
2009-03-03 12:00:10,125 INFO  XmlBeanDefinitionReader - Loading XML bean
definitions from file
[D:\Dvlpt\Java\workspace-ganymede\osgi\reportincident.interfaces\target\classes\META-INF\spring\camel-context.xml]
 
2009-03-03 12:00:10,140 DEBUG DefaultDocumentLoader - Using JAXP provider
[com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl] 
2009-03-03 12:00:10,203 DEBUG PluggableSchemaResolver - Loading schema
mappings from [META-INF/spring.schemas] 
2009-03-03 12:00:10,218 DEBUG PluggableSchemaResolver - Loaded schema
mappings:
{http://activemq.apache.org/camel/schema/spring/camel-spring-1.5.0.xsd=camel-spring.xsd,
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd,
http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd,
http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd,
http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-2.5.xsd,
http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-2.5.xsd,
http://camel.apache.org/schema/spring/camel-spring-2.0-SNAPSHOT.xsd=camel-spring.xsd,
http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd,
http://activemq.apache.org/camel/schema/spring/camel-spring-1.2.0.xsd=camel-spring.xsd,
http://activemq.apache.org/camel/schema/spring/camel-spring-1.1.0.xsd=camel-spring.xsd,
http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd,
http://activemq.apache.org/camel/schema/spring/camel-spring-1.0.0.xsd=camel-spring.xsd,
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd,
http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd,
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd,
http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd,
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd,

Re: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.component.file.GenericFileMessage to the required type - SMX4 !

2009-03-03 Thread cmoulliard

Hi Willem,

It works (I mean the file can be processed by Camel) but 

1) in DEBUG mode, the log of SMX4 server is polluted by hundreds of line
like this :

12:11:01,687 | DEBUG | ompon...@1d4f279 | ResolverUtil |
g.apache.camel.util.ResolverUtil  571 | Could not find class
'org/apache/camel/converter/stream/StreamCacheConverter$InputStreamCache.class'
in classloader: BundleDelegatingClassLoader for [Report Incident Interfaces
Bundle (reportincident.interfaces)]. Reason:
java.lang.ClassNotFoundException:
org.apache.camel.converter.stream.StreamCacheConverter$InputStreamCache not
found from bundle [reportincident.interfaces]
java.lang.ClassNotFoundException:
org.apache.camel.converter.stream.StreamCacheConverter$InputStreamCache not
found from bundle [reportincident.interfaces]
at
org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)
at
org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at 
org.apache.camel.util.ResolverUtil.addIfMatching(ResolverUtil.java:561)
at
org.apache.camel.osgi.OsgiResolverUtil.loadImplementationsInBundle(OsgiResolverUtil.java:135)
at
org.apache.camel.osgi.OsgiResolverUtil.findInOsgiClassLoader(OsgiResolverUtil.java:92)
at org.apache.camel.osgi.OsgiResolverUtil.find(OsgiResolverUtil.java:73)
at 
org.apache.camel.util.ResolverUtil.findAnnotated(ResolverUtil.java:301)
at
org.apache.camel.impl.converter.AnnotationTypeConverterLoader.load(AnnotationTypeConverterLoader.java:73)
at
org.apache.camel.impl.converter.DefaultTypeConverter.checkLoaded(DefaultTypeConverter.java:296)
at
org.apache.camel.impl.converter.DefaultTypeConverter.convertTo(DefaultTypeConverter.java:98)
at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:66)
at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:51)
at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:74)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
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: java.lang.ClassNotFoundException:
org.apache.camel.converter.stream.StreamCacheConverter$InputStreamCache
at
org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:566)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)
at
org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1371)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at
org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(ModuleImpl.java:428)
at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1341)
at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:737)
at
org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)
... 26 more

2) I have a more serious problem. The classes of my model are not loaded. In
DEBUG mode, we should see this on the console 

2009-03-03 12:28:34,671 DEBUG ResolverUtil - Searching for annotations of
[interface org.apache.camel.dataformat.bindy.annotation.CsvRecord, interface
org.apache.camel.dataformat.bindy.annotation.Link, interface
org.apache.camel.dataformat.bindy.annotation.Message] in packages:
[org.apache.camel.example.reportincident.model] 
2009-03-03 12:28:34,687 DEBUG ResolverUtil - Using only regular classloaders 
2009-03-03 12:28:34,687 DEBUG ResolverUtil - Loading from directory:

Re: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.component.file.GenericFileMessage to the required type - SMX4 !

2009-03-03 Thread Claus Ibsen
Hi

Yeah this resolver needs to be OSGi aware also.

I think we need to provide these resolvers on the CamelContext so
component authors like you can use them to resolve classes and
whatelse, and it would be transparent for you if it was regular or
OSGi platforms.

See ticket 1411 that is about this. Just need to add getResolverUtil
as well, and we should probably rename it as its a bad name to put out
in the open.
We need an API for it as well in the SPI package.

There is a mail on the dev forum about this as well to disucss it there.

The DEBUG logging could maybe be toned down to TRACE


On Tue, Mar 3, 2009 at 12:32 PM, cmoulliard cmoulli...@gmail.com wrote:

 Hi Willem,

 It works (I mean the file can be processed by Camel) but

 1) in DEBUG mode, the log of SMX4 server is polluted by hundreds of line
 like this :

 12:11:01,687 | DEBUG | ompon...@1d4f279 | ResolverUtil                     |
 g.apache.camel.util.ResolverUtil  571 | Could not find class
 'org/apache/camel/converter/stream/StreamCacheConverter$InputStreamCache.class'
 in classloader: BundleDelegatingClassLoader for [Report Incident Interfaces
 Bundle (reportincident.interfaces)]. Reason:
 java.lang.ClassNotFoundException:
 org.apache.camel.converter.stream.StreamCacheConverter$InputStreamCache not
 found from bundle [reportincident.interfaces]
 java.lang.ClassNotFoundException:
 org.apache.camel.converter.stream.StreamCacheConverter$InputStreamCache not
 found from bundle [reportincident.interfaces]
        at
 org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)
        at
 org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at 
 org.apache.camel.util.ResolverUtil.addIfMatching(ResolverUtil.java:561)
        at
 org.apache.camel.osgi.OsgiResolverUtil.loadImplementationsInBundle(OsgiResolverUtil.java:135)
        at
 org.apache.camel.osgi.OsgiResolverUtil.findInOsgiClassLoader(OsgiResolverUtil.java:92)
        at 
 org.apache.camel.osgi.OsgiResolverUtil.find(OsgiResolverUtil.java:73)
        at 
 org.apache.camel.util.ResolverUtil.findAnnotated(ResolverUtil.java:301)
        at
 org.apache.camel.impl.converter.AnnotationTypeConverterLoader.load(AnnotationTypeConverterLoader.java:73)
        at
 org.apache.camel.impl.converter.DefaultTypeConverter.checkLoaded(DefaultTypeConverter.java:296)
        at
 org.apache.camel.impl.converter.DefaultTypeConverter.convertTo(DefaultTypeConverter.java:98)
        at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:66)
        at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:51)
        at
 org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:74)
        at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
        at
 org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:170)
        at
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103)
        at
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66)
        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: java.lang.ClassNotFoundException:
 org.apache.camel.converter.stream.StreamCacheConverter$InputStreamCache
        at
 org.apache.felix.framework.searchpolicy.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:566)
        at
 org.apache.felix.framework.searchpolicy.ModuleImpl.access$100(ModuleImpl.java:59)
        at
 org.apache.felix.framework.searchpolicy.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1371)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at
 org.apache.felix.framework.searchpolicy.ModuleImpl.getClassByDelegation(ModuleImpl.java:428)
        at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1341)
        at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:737)
        at
 

Re: Classloading and OSGI

2009-03-03 Thread atlep

No they don't..

I peeked into the code that tries to load the QueueBrowserStrategy, and it
seemt that it doesnt try the contextclasslaoder at all (I am using camel
1.5.0), did i peek hard enough?

Ideally one don't want to have references to packages other than camel-core,
and let camel sort the refrences out. In osgi cases when the classloader is
important one could have some explicit classloader configuration in
camelContext..

I will try to check the 2.0 fix, thank you for your help! :)

willem.jiang wrote:
 
 I just want to ask a question, did your bundle has the import of
 org.apache.camel.component.jms.* ?
 
 If so, the ObjectHelper should be able to load the default
 QueueBrowserStrategy.
 
 Willem
 
 
 willem.jiang wrote:
 
 Hi ,  
 
 I just created a JIRA[1] for your issue.
 And will commit a quick fix for it.
 If you have time please check out the latest camel 2.0 snapshot to verify
 it.
 
 [1] https://issues.apache.org/activemq/browse/CAMEL-1412
 
 Willem
 
 
 atlep wrote:
 
 I am using camel in  a OSGI (Felix) environment, and I regularly bump
 into classloading issues:
 
 THe most recentones are
 The JSM Component cant find the QueueBrowserStrategy because it cannot
 see the spring bundle that exports it, because it is using a wrong 
 classloader to try to load it (it uses o.a.c.util.ObjectHelper's
 classloader).
 
 The activemq component cannot load object messages because it cannot
 deserialize the body. I have tried setting the thread contextclassloader
 to my bundles classloader, but it seems it does not use the context
 classloader.
 
 Are there any good practices or patterns regarding using camel +
 activemq in a OSGi environment, without resorting to servicemix? 
 
 Maybe these wrinkles are ironed out in camel 2.0?
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Classloading-and-OSGI-tp22303475p22309259.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.



Re: Classloading and OSGI

2009-03-03 Thread Willem Jiang
ObjectHelper will load the class with trying to use the
threadContextClassLoader first.

Since your bundle doen't import the org.apache.camel.component.jms.*.
The threadContextClassLoader which is set to use your bundle classloader
can't see the QueueBrowserStrategy. You will get the ClassNotFoundException.

I did a little trick to let the ObjectHelper to load class with the
JmsComponent's classloader. Hope it can work in your case, if you don't
want to change you bundle's META-INF\MANIFEST.MF import package.

-Class? type =
ObjectHelper.loadClass(DEFAULT_QUEUE_BROWSE_STRATEGY);
+Class? type =
ObjectHelper.loadClass(DEFAULT_QUEUE_BROWSE_STRATEGY,
JmsComponent.class.getClassLoader());


Willem


atlep wrote:
 No they don't..
 
 I peeked into the code that tries to load the QueueBrowserStrategy, and it
 seemt that it doesnt try the contextclasslaoder at all (I am using camel
 1.5.0), did i peek hard enough?
 
 Ideally one don't want to have references to packages other than camel-core,
 and let camel sort the refrences out. In osgi cases when the classloader is
 important one could have some explicit classloader configuration in
 camelContext..
 
 I will try to check the 2.0 fix, thank you for your help! :)
 
 willem.jiang wrote:
 I just want to ask a question, did your bundle has the import of
 org.apache.camel.component.jms.* ?

 If so, the ObjectHelper should be able to load the default
 QueueBrowserStrategy.

 Willem


 willem.jiang wrote:
 Hi ,  

 I just created a JIRA[1] for your issue.
 And will commit a quick fix for it.
 If you have time please check out the latest camel 2.0 snapshot to verify
 it.

 [1] https://issues.apache.org/activemq/browse/CAMEL-1412

 Willem


 atlep wrote:
 I am using camel in  a OSGI (Felix) environment, and I regularly bump
 into classloading issues:

 THe most recentones are
 The JSM Component cant find the QueueBrowserStrategy because it cannot
 see the spring bundle that exports it, because it is using a wrong 
 classloader to try to load it (it uses o.a.c.util.ObjectHelper's
 classloader).

 The activemq component cannot load object messages because it cannot
 deserialize the body. I have tried setting the thread contextclassloader
 to my bundles classloader, but it seems it does not use the context
 classloader.

 Are there any good practices or patterns regarding using camel +
 activemq in a OSGi environment, without resorting to servicemix? 

 Maybe these wrinkles are ironed out in camel 2.0?