You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by adie <ma...@mirailabs.com> on 2016/11/07 18:03:55 UTC
IllegalStateException: Current exchange has not been set for
ExpressionMapper while converting a CXF object
Hi!
I was trying to use camel-dozer component to translate a POJO generated by
CXF.
1. First I started with simple mapping of two fields 1:1 and URI with
targetModel and mappingFile. Which actually failed, because POJO was wrapped
in some object.
2. Then I've added sourceModel and it worked using following URI.
3. Then I was trying to use Camel expressions like this
... but it failed with error
I was trying to debug the error and it seems that thread local variable does
not contain current Exchange.
I am using Camel 2.17 (including all dependencies - Dozer 5.5.1) plus I am
running this in a test using camel-test-blueprint
Is there any dependency or declaration I need to make to use expression
mapping?
Let me know if you need more details.
Many thanks,
Marcin
--
View this message in context: http://camel.465427.n5.nabble.com/IllegalStateException-Current-exchange-has-not-been-set-for-ExpressionMapper-while-converting-a-CXF-t-tp5789866.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: IllegalStateException: Current exchange has not been set for
ExpressionMapper while converting a CXF object
Posted by adie <ma...@mirailabs.com>.
Many thanks Tomo!
I did not notice that you need to use a specific class-a and source field. I
was trying to use both classic mapping and expression mapping at the same
time. It seems to use expression mapping you need following:
- "class-a" element must be exactly
"org.apache.camel.component.dozer.ExpressionMapper" you cannot put your
custom class here
- "custom-converter-id" must be exactly "_expressionMapping"
- field "a" should always be "expression"
This brings some limitations, like:
- if you set class-a to the ExpressionMapper you are required to use
expression mapping for all fields in this mapping
- mapping is one-direction because the way it works
- you cannot have two mappings with same target class but different expected
sources.
Correct?
Somehow, I can live with this limitations as long as I am aware of them...
Many thanks,
Marcin
--
View this message in context: http://camel.465427.n5.nabble.com/IllegalStateException-Current-exchange-has-not-been-set-for-ExpressionMapper-while-converting-a-CXF-t-tp5789866p5789896.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: IllegalStateException: Current exchange has not been set for
ExpressionMapper while converting a CXF object
Posted by Tomohisa Igarashi <tm...@gmail.com>.
Hi,
There're some testcases demonstrating expression mapping like this:
https://github.com/apache/camel/blob/master/components/camel-dozer/src/test/resources/org/apache/camel/component/dozer/ExpressionMappingTest-context.xml
https://github.com/apache/camel/blob/master/components/camel-dozer/src/test/resources/org/apache/camel/component/dozer/expressionMappingFile.xml
Would you take a look at these and see what is different from yours?
Also you may want to try with latest 2.17.3 or 2.18.0.
Thanks,
Tomo
On 11/08/2016 03:03 AM, adie wrote:
> Hi!
> I was trying to use camel-dozer component to translate a POJO generated by
> CXF.
>
> 1. First I started with simple mapping of two fields 1:1 and URI with
> targetModel and mappingFile. Which actually failed, because POJO was wrapped
> in some object.
> 2. Then I've added sourceModel and it worked using following URI.
>
> 3. Then I was trying to use Camel expressions like this
>
>
> ... but it failed with error
>
>
> I was trying to debug the error and it seems that thread local variable does
> not contain current Exchange.
>
> I am using Camel 2.17 (including all dependencies - Dozer 5.5.1) plus I am
> running this in a test using camel-test-blueprint
>
>
> Is there any dependency or declaration I need to make to use expression
> mapping?
>
> Let me know if you need more details.
>
> Many thanks,
> Marcin
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/IllegalStateException-Current-exchange-has-not-been-set-for-ExpressionMapper-while-converting-a-CXF-t-tp5789866.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>