You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by geppo <ge...@gmail.com> on 2015/01/22 12:46:31 UTC

Cannot cast DefaultCamelContext to ModelCamelContext

Hi, I've written a JUnit test in Eclipse for a Camel route.
It has been working fine for days, but now it doesn't startup failing in the
CamelTestSupport.setUp method:



I've tried to cleanup the Maven repository especially the camel-core,
camel-test and junit repositories.
When I right-click on the CamelTestSupport class in Eclipse it says it comes
from the camel-test jar version 2.9.3 (which should match the camel-core)
although I found in the past that Eclipse often lies on which version is
actually using (if you have multiple ones in your Maven repository).
Junit version used should be 4.8.1 (again that's what Eclipse says at
least...).
I suspect it's a problem with libraries versions.

Any idea?



--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-cast-DefaultCamelContext-to-ModelCamelContext-tp5762011.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot cast DefaultCamelContext to ModelCamelContext

Posted by geppo <ge...@gmail.com>.
Found the problem, my project is using Camel 2.9.3, but it has a dependency
on another project which uses Camel 2.8.0 and for whatever reason the lower
version jar is the one loaded by Eclipse when running the test.
Thanks for your help!



--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-cast-DefaultCamelContext-to-ModelCamelContext-tp5762012p5762017.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot cast DefaultCamelContext to ModelCamelContext

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah such kind of errors can often be about mixed versions of a
library on the class path etc. So I would double check that you only
use same version of Camel.

If you use maven then check the pom.xml

On Thu, Jan 22, 2015 at 1:19 PM, geppo <ge...@gmail.com> wrote:
> I am not type casting myself.
> The cast is inside the class CamelTestSupport:
>
>
>
> All I'm doing is overriding the createCamelContext, which I've done
> succesfully in the past:
>
> Do you know if the DefaultCamelContext in a previous version of Camel didn't
> implement the interface ModelCamelContext?
> Maybe Eclipse is picking up an older version from the Maven repository.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Cannot-cast-DefaultCamelContext-to-ModelCamelContext-tp5762012p5762015.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Cannot cast DefaultCamelContext to ModelCamelContext

Posted by geppo <ge...@gmail.com>.
I am not type casting myself.
The cast is inside the class CamelTestSupport:



All I'm doing is overriding the createCamelContext, which I've done
succesfully in the past:

Do you know if the DefaultCamelContext in a previous version of Camel didn't
implement the interface ModelCamelContext?
Maybe Eclipse is picking up an older version from the Maven repository.




--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-cast-DefaultCamelContext-to-ModelCamelContext-tp5762012p5762015.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot cast DefaultCamelContext to ModelCamelContext

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah sounds strange as they are both from the very same jar - camel-core.

btw you do not need to type cast you can use the api on camel context.
which we may consider removing the @deprecation as its more annoying than good.

And instead of type cast we should add an adapt(T) method for ppl to
use if they really wanna work wit the model camel context

On Thu, Jan 22, 2015 at 12:46 PM, geppo <ge...@gmail.com> wrote:
> Hi, I've written a JUnit test in Eclipse for a Camel route.
> It has been working fine for days, but now it doesn't startup failing in the
> CamelTestSupport.setUp method:
>
>
>
> I've tried to cleanup the Maven repository especially the camel-core,
> camel-test and junit repositories.
> When I right-click on the CamelTestSupport class in Eclipse it says it comes
> from the camel-test jar version 2.9.3 (which should match the camel-core)
> although I found in the past that Eclipse often lies on which version is
> actually using (if you have multiple ones in your Maven repository).
> Junit version used should be 4.8.1 (again that's what Eclipse says at
> least...).
> I suspect it's a problem with libraries versions.
>
> Any idea?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Cannot-cast-DefaultCamelContext-to-ModelCamelContext-tp5762011.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/