Convert jaxb xml message to base type in apache camel (java) -



Convert jaxb xml message to base type in apache camel (java) -

i'm trying build global error handler of camel (v 2.13.1) routes. if exception bubbles error handler log , send team email.

i'm having problems polymorphism , jaxb annotated messages, though. of messages similar this:

@xmlrootelement @xmlaccessortype(value = xmlaccesstype.property) @xmltype(proporder = {}) static abstract class request { @xmlelement(required = true) abstract string getthing(); abstract void setthing(final string thing); } @xmlrootelement @xmlaccessortype(value = xmlaccesstype.property) @xmltype(proporder = {}) static class myrequest extends request { private string name; @xmlelement(required = true) public string getname() { homecoming name; } public void setname(final string name) { this.name = name; } private string thing; @override @xmlelement(required = true) public string getthing() { homecoming thing; } public void setthing(final string thing) { this.thing = thing; } }

my error route i'm playing around looks this:

from (errorqueue) .convertbodyto(request.class) .process(new processor() { @override public void process(exchange exchange) throws exception { final request req = exchange.getin().getbody(request.class); log.info("name = {}, thing = {}", null, req.getthing()); } });

depending on component fails, message myrequest, myotherrequest, etc. of messages inherit request. here particular message testing with:

<myrequest> <name>some_name</name> <thing>some_thing</thing> </myrequest>

when run errors like:

caused by: javax.xml.bind.unmarshalexception: unexpected element (uri:"", local:"myrequest"). expected elements <{}request>

how can convert jaxb annotated messages various types base of operations type can info base of operations class?

i prefer using interface instead of base of operations class, had similar results.

metadata may not getting processed myrequest class, subclasses not in. seek adding @xmlseealso annotation on super class:

@xmlrootelement @xmlaccessortype(value = xmlaccesstype.property) @xmltype(proporder = {}) @xmlseealso({myrequest.class}) static abstract class request {

java jaxb apache-camel

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -