Thanks Freeman, it works by specifying the 'provided' scope and adding the
following snippet to my camel-context.xml:
<classpath>
<library>osgi:org.milyn.smooks.osgi</library>
</classpath>
But as someone who wants all the corners round, there is one last question:
Does the classpath tag belong to any namespace?
*Henrique Viecili*
Myreks
On Thu, Feb 23, 2012 at 11:25 PM, Freeman Fang <[email protected]>wrote:
> Hi,
>
> My comment inline
>
> On 2012-2-23, at 下午11:23, Henrique Viecilli wrote:
>
> Hi fellows!
>>
>> I am following some scarce resources in the web to enable my *JBI
>> Service*to use Smooks to unmarshal a CSV straight to XML (migrating
>>
>> from JBossESB).
>>
>> I've installed the Smooks OSGi feature in my ServiceMix (4.4.1 fuse-01-13)
>> instance with:
>>
>> features:addUrl mvn:org.milyn/milyn-smooks-**all/1.5/xml/features *(not
>> the
>> SNAPSHOT)*
>>
>> features:install smooks
>>
>> at first I just added my smooks-config.xml and the SmooksDataFormat
>> declaration in my camel-context.xml:
>>
>> <bean id="smooks"
>> class="org.milyn.smooks.camel.**dataformat.SmooksDataFormat">
>>
>> <constructor-arg><value>META-**INF/resources/normalization/**
>> smooks-config.xml</value></**constructor-arg>
>> </bean>
>>
>> then I packaged the SA and deployed to SMX, which gave me a
>> ClassNotFoundException: org.milyn.smooks.camel.**
>> dataformat.SmooksDataFormat,
>> so I figured I should add the smooks dependency to my pom.xml:
>>
>> <dependency>
>> <groupId>org.milyn</groupId>
>> <artifactId>milyn-smooks-**camel</artifactId>
>> <version>1.5</version>
>> </dependency>
>>
> You should add
> <scope>provided</scope>
> here, that can avoid package the milyn-smooks into your SA.
> If you package milyn-smook into your SA, then you actually have two copy
> of milyn-smooks, one is the bundle from
> OSGi container, one is from your SA, which cause the ClassCastException,
> as they are from different classloaders.
>
> Also in your SU's xbean.xml, you need refer classes from milyn-smooks,
> take a look at[1], the "New in ServiceMix 4.2.0" chapter.
>
> [1]http://servicemix.apache.**org/classloaders.html<http://servicemix.apache.org/classloaders.html>
>
> Freeman
>
>>
>> packaged and deployed again, and now I am afraid I'm stuck with a
>> classloading issue: ClassCastException: org.milyn.SmooksOSGIFactory cannot
>> be cast to org.milyn.SmooksFactory (SmooksOSGIFactory implements
>> SmooksFactory).
>>
>> I guess the SmooksOSGIFactory has a diferent classloader then the current
>> classloader of my JBI Service, thus throwing the ClassCastException. Am I
>> right? How do I fix this? I would like to avoid packaging all smooks
>> dependencies in my SU/SA.
>>
>> Thanks,
>> *Henrique Viecili*
>>
>> Myreks
>>
>> Resources:
>> http://blog.smooks.org/2011/**02/19/smooks-osgi-revisited/<http://blog.smooks.org/2011/02/19/smooks-osgi-revisited/>
>> http://blog.smooks.org/2010/**02/22/apache-camel-smooks/<http://blog.smooks.org/2010/02/22/apache-camel-smooks/>
>> https://github.com/smooks/**smooks/tree/v1.4/smooks-**examples/camel<https://github.com/smooks/smooks/tree/v1.4/smooks-examples/camel>
>>
>
> ------------------------------**---------------
> Freeman Fang
>
> FuseSource
> Email:[email protected]
> Web: fusesource.com
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.**com <http://freemanfang.blogspot.com>
>
>
>
>
>
>
>
>
>
>