You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ivan Stojic <iv...@gmail.com> on 2008/05/28 18:53:26 UTC

Problem with TypeConverters in OSGi

Hi,

I tried deploying some of my existing Camel routes into an OSGi enviroment
(Camel 1.3.0 / ServiceMix 4 Kernel / Apache Felix) and I noticed that all of
the TypeConverters stopped working, even the basic ones (e.g. byte[] to
String). I found this error in the log:

18:26:04,982 | ERROR | ExtenderThread-4 | ResolverUtil |
g.apache.camel.util.ResolverUtil  364 | Could not search jar file
'/org/apache/camel/converter' for classes matching criteria: annotated with
@Converterdue to an IOException: /org/apache/camel/converter (No such file
or directory)

I guess ResolverUtil tries to find and open the .jar file but gets confused
if the package is in an OSGi bundle. I checked the camel-osgi module, but it
only seems to add support for searching for Camel components in active OSGi
bundles, and not TypeConverters.

Is there a way to fix this?

Thanks,
Ivan
-- 
View this message in context: http://www.nabble.com/Problem-with-TypeConverters-in-OSGi-tp17517233s22882p17517233.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Problem with TypeConverters in OSGi

Posted by Guillaume Nodet <gn...@gmail.com>.
OSGi is a kinda different beast though ...
I'll try to have a look at that.

On Thu, May 29, 2008 at 1:46 PM, Claus Ibsen <ci...@silverbullet.dk> wrote:
> Hi
>
> Try adding log4j trace level debugging as Camel ResolverUtil does trace logging while it tries to load the class ressource.
>
>
> And for fix of the bug could potential look how Spring does ressource loading as they have fought with all kind of weird situations with loading from WebSphere, WebLogic, JBoss etc. that does strange tricks
>
>
> Med venlig hilsen
>
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
>
> -----Original Message-----
> From: Ivan Stojic [mailto:ivanzgb@gmail.com]
> Sent: 29. maj 2008 13:24
> To: camel-user@activemq.apache.org
> Subject: Re: Problem with TypeConverters in OSGi
>
>
> Hi,
>
> I tried using this Camel route builder:
>
> package test;
> import org.apache.camel.builder.RouteBuilder;
> public class MyRouteBuilder extends RouteBuilder {
>    public void configure() throws Exception {
>
>        from("timer://myTimer?period=2000")
>            .setBody(constant(new byte[]{'H','e','l','l','o'}))
>            .convertBodyTo(String.class)
>            .to("log:Test");
>    }
> }
>
> Running it in normal Java SE (without OSGi) I get correct log output:
>
> INFO: Exchange[Message: Hello]
>
> Runing it inside SMX Kernel, I get:
>
> 12:51:02,415 | ERROR | xtenderThread-28 | ResolverUtil |
> er.AnnotationTypeConverterLoader   58 | Could not search jar file
> '/org/apache/camel/converter' for classes matching criteria: annotated with
> @Converterdue to an IOException: /org/apache/camel/converter (No such file
> or directory)
> [...]
> 12:51:06,449 | INFO  | myTimer          | Test|
> che.camel.impl.ProcessorEndpoint   72 | Exchange[Message: [B@11dfada]
>
> It should be 'Hello' instead of '[B@11dfada]'
>
> Btw, I also just noticed that if I define my OSGi CamelContext with Spring
> like this:
>
> <osgi:camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
>  <package>test</package>
> </osgi:camelContext>
>
> I also get an error:
>
> 13:08:06,790 | ERROR | xtenderThread-33 | ResolverUtil |
> .camel.spring.RouteBuilderFinder   73 | Could not search jar file '/test'
> for classes matching criteria: is assignable to RouteBuilderdue to an
> IOException: /test (No such file or directory)
>
> and no routes get created. Instead I had to use:
>
> <osgi:camelContext/>
> <bean class="test.MyRouteBuilder" />
>
> Let me know if there is anything else I could do to help.
>
> Thanks,
> Ivan
>
>
> gnodet wrote:
>>
>> Thx, could you give some informations on how to reproduce the problem ?
>> Maybe the code of a simple OSGi bundle that fails ?
>>
>> On Thu, May 29, 2008 at 10:35 AM, Ivan Stojic <iv...@gmail.com> wrote:
>>>
>>> Sure:
>>>
>>> https://issues.apache.org/activemq/browse/CAMEL-558
>>>
>>>
>>> Ivan
>>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Problem-with-TypeConverters-in-OSGi-tp17517233s22882p17532737.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

RE: Problem with TypeConverters in OSGi

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Try adding log4j trace level debugging as Camel ResolverUtil does trace logging while it tries to load the class ressource.


And for fix of the bug could potential look how Spring does ressource loading as they have fought with all kind of weird situations with loading from WebSphere, WebLogic, JBoss etc. that does strange tricks


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Ivan Stojic [mailto:ivanzgb@gmail.com] 
Sent: 29. maj 2008 13:24
To: camel-user@activemq.apache.org
Subject: Re: Problem with TypeConverters in OSGi


Hi,

I tried using this Camel route builder:

package test;
import org.apache.camel.builder.RouteBuilder;
public class MyRouteBuilder extends RouteBuilder {
    public void configure() throws Exception {

        from("timer://myTimer?period=2000")
            .setBody(constant(new byte[]{'H','e','l','l','o'}))
            .convertBodyTo(String.class)
            .to("log:Test");
    }
}

Running it in normal Java SE (without OSGi) I get correct log output:

INFO: Exchange[Message: Hello]

Runing it inside SMX Kernel, I get:

12:51:02,415 | ERROR | xtenderThread-28 | ResolverUtil |
er.AnnotationTypeConverterLoader   58 | Could not search jar file
'/org/apache/camel/converter' for classes matching criteria: annotated with
@Converterdue to an IOException: /org/apache/camel/converter (No such file
or directory)
[...]
12:51:06,449 | INFO  | myTimer          | Test|
che.camel.impl.ProcessorEndpoint   72 | Exchange[Message: [B@11dfada]

It should be 'Hello' instead of '[B@11dfada]'

Btw, I also just noticed that if I define my OSGi CamelContext with Spring
like this:

<osgi:camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
  <package>test</package>
</osgi:camelContext>

I also get an error:

13:08:06,790 | ERROR | xtenderThread-33 | ResolverUtil |
.camel.spring.RouteBuilderFinder   73 | Could not search jar file '/test'
for classes matching criteria: is assignable to RouteBuilderdue to an
IOException: /test (No such file or directory)

and no routes get created. Instead I had to use:

<osgi:camelContext/>
<bean class="test.MyRouteBuilder" />

Let me know if there is anything else I could do to help.

Thanks,
Ivan


gnodet wrote:
> 
> Thx, could you give some informations on how to reproduce the problem ?
> Maybe the code of a simple OSGi bundle that fails ?
> 
> On Thu, May 29, 2008 at 10:35 AM, Ivan Stojic <iv...@gmail.com> wrote:
>>
>> Sure:
>>
>> https://issues.apache.org/activemq/browse/CAMEL-558
>>
>>
>> Ivan
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-TypeConverters-in-OSGi-tp17517233s22882p17532737.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Problem with TypeConverters in OSGi

Posted by Ivan Stojic <iv...@gmail.com>.
Hi,

I tried using this Camel route builder:

package test;
import org.apache.camel.builder.RouteBuilder;
public class MyRouteBuilder extends RouteBuilder {
    public void configure() throws Exception {

        from("timer://myTimer?period=2000")
            .setBody(constant(new byte[]{'H','e','l','l','o'}))
            .convertBodyTo(String.class)
            .to("log:Test");
    }
}

Running it in normal Java SE (without OSGi) I get correct log output:

INFO: Exchange[Message: Hello]

Runing it inside SMX Kernel, I get:

12:51:02,415 | ERROR | xtenderThread-28 | ResolverUtil |
er.AnnotationTypeConverterLoader   58 | Could not search jar file
'/org/apache/camel/converter' for classes matching criteria: annotated with
@Converterdue to an IOException: /org/apache/camel/converter (No such file
or directory)
[...]
12:51:06,449 | INFO  | myTimer          | Test|
che.camel.impl.ProcessorEndpoint   72 | Exchange[Message: [B@11dfada]

It should be 'Hello' instead of '[B@11dfada]'

Btw, I also just noticed that if I define my OSGi CamelContext with Spring
like this:

<osgi:camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
  <package>test</package>
</osgi:camelContext>

I also get an error:

13:08:06,790 | ERROR | xtenderThread-33 | ResolverUtil |
.camel.spring.RouteBuilderFinder   73 | Could not search jar file '/test'
for classes matching criteria: is assignable to RouteBuilderdue to an
IOException: /test (No such file or directory)

and no routes get created. Instead I had to use:

<osgi:camelContext/>
<bean class="test.MyRouteBuilder" />

Let me know if there is anything else I could do to help.

Thanks,
Ivan


gnodet wrote:
> 
> Thx, could you give some informations on how to reproduce the problem ?
> Maybe the code of a simple OSGi bundle that fails ?
> 
> On Thu, May 29, 2008 at 10:35 AM, Ivan Stojic <iv...@gmail.com> wrote:
>>
>> Sure:
>>
>> https://issues.apache.org/activemq/browse/CAMEL-558
>>
>>
>> Ivan
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-TypeConverters-in-OSGi-tp17517233s22882p17532737.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Problem with TypeConverters in OSGi

Posted by Guillaume Nodet <gn...@gmail.com>.
Thx, could you give some informations on how to reproduce the problem ?
Maybe the code of a simple OSGi bundle that fails ?

On Thu, May 29, 2008 at 10:35 AM, Ivan Stojic <iv...@gmail.com> wrote:
>
> Sure:
>
> https://issues.apache.org/activemq/browse/CAMEL-558
>
>
> Ivan
>
>
> Claus Ibsen wrote:
>>
>> Hi
>>
>> Could you raise this as a bug/improvement in the JIRA?
>>
>>
>> Med venlig hilsen
>>
>> Claus Ibsen
>> ......................................
>> Silverbullet
>> Skovsgårdsvænget 21
>> 8362 Hørning
>> Tlf. +45 2962 7576
>> Web: www.silverbullet.dk
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Problem-with-TypeConverters-in-OSGi-tp17517233s22882p17530138.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

RE: Problem with TypeConverters in OSGi

Posted by Ivan Stojic <iv...@gmail.com>.
Sure:

https://issues.apache.org/activemq/browse/CAMEL-558


Ivan


Claus Ibsen wrote:
> 
> Hi
> 
> Could you raise this as a bug/improvement in the JIRA?
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-TypeConverters-in-OSGi-tp17517233s22882p17530138.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Problem with TypeConverters in OSGi

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Could you raise this as a bug/improvement in the JIRA?


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Ivan Stojic [mailto:ivanzgb@gmail.com] 
Sent: 28. maj 2008 18:53
To: camel-user@activemq.apache.org
Subject: Problem with TypeConverters in OSGi


Hi,

I tried deploying some of my existing Camel routes into an OSGi enviroment
(Camel 1.3.0 / ServiceMix 4 Kernel / Apache Felix) and I noticed that all of
the TypeConverters stopped working, even the basic ones (e.g. byte[] to
String). I found this error in the log:

18:26:04,982 | ERROR | ExtenderThread-4 | ResolverUtil |
g.apache.camel.util.ResolverUtil  364 | Could not search jar file
'/org/apache/camel/converter' for classes matching criteria: annotated with
@Converterdue to an IOException: /org/apache/camel/converter (No such file
or directory)

I guess ResolverUtil tries to find and open the .jar file but gets confused
if the package is in an OSGi bundle. I checked the camel-osgi module, but it
only seems to add support for searching for Camel components in active OSGi
bundles, and not TypeConverters.

Is there a way to fix this?

Thanks,
Ivan
-- 
View this message in context: http://www.nabble.com/Problem-with-TypeConverters-in-OSGi-tp17517233s22882p17517233.html
Sent from the Camel - Users mailing list archive at Nabble.com.