camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From contactreji <contactr...@gmail.com>
Subject Json format disturbed // Rest DSL + Jackson
Date Mon, 19 Dec 2016 16:49:31 GMT
Hi 

I am trying to expose a rest endpoint from camel. Below is the route.

*package com.tgt.worker.routes;

import com.tgt.student.StudentPojo;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jackson.JacksonDataFormat;
import org.apache.camel.model.rest.RestBindingMode;
import org.restlet.data.MediaType;
import org.springframework.stereotype.Component;


@Component
public class RestDSL extends RouteBuilder{
    @Override
    public void configure() throws Exception {

        JacksonDataFormat student = new
JacksonDataFormat(StudentPojo.class);


       
restConfiguration().component("restlet").host("localhost").port(1212)
                .bindingMode(RestBindingMode.auto)
                .dataFormatProperty("prettyPrint", "true");

        rest("/travel/")
                .produces(MediaType.APPLICATION_JSON.toString())
                .consumes(MediaType.APPLICATION_JSON.toString())
                .put().to("direct:addStudents");


        from("direct:addStudents")
                .log("Received data ${body}")
                .convertBodyTo(String.class)
                .unmarshal(student)
                .transform(constant("done"))
                .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200))
                .log("RETURNING ${body}")
                .end();

    }
}*



Unfortunately, when i push some json from httpclient, I see that the double
quotes on fields get disappeared when it comes to route. And Jackson throws
an error. Can someone help me understand why this quotes disappear? Find the
logs below.


*
2016-12-19 22:09:48 INFO  com.tgt.worker.WorkerApplication - Started
WorkerApplication in 5.279 seconds (JVM running for 5.681)
2016-12-19 22:09:58 INFO  route2 - Received data
{students={@expansions=demographics, addresses, alerts, phones,
school_enrollment, ethnicity_race, contact, contact_info,
initial_enrollment, schedule_setup, fees, lunch,
@extensions=activities,c_studentlocator,u_students_extension,u_bus,
student=[{id=2, local_id=3, student_username=ag1student1,
name={first_name=Brandon, last_name=Adair}, demographics={gender=M,
birth_date=1998-12-13, projected_graduation_year=2016},
addresses={physical={street=1337 Greymont Ave, city=Jackson,
state_province=MS, postal_code=39202}, mailing={street=1337 Greymont Ave,
city=Jackson, state_province=MS, postal_code=39202}},
alerts={legal={description=Divorced parents only mom should pick up,
expires_date=NEVER_EXPIRES}, discipline={description=Fighting is a problem,
expires_date=NEVER_EXPIRES}, medical={description=Allergic to peanuts,
expires_date=NEVER_EXPIRES}, other={description=Brandon needs to go to study
hall during 3rd period., expires_date=NEVER_EXPIRES}},
phones={main={number=1-555-555-3612}}, school_enrollment={enroll_status=A,
enroll_status_description=Active, enroll_status_code=0, grade_level=12,
entry_date=2015-05-25, exit_date=2016-05-22, school_number=100, school_id=3,
entry_code=A1, entry_comment=promoted, track=A,
full_time_equivalency={fteid=854, name=Full Time}},
ethnicity_race={scheduling_reporting_ethnicity=B},
contact={emergency_contact_name1=Jonathan Mccarthy,
emergency_phone1=1-555-555-6049, emergency_phone2=1-555-555-2202,
guardian_email=example217457@marketvolt.com, mother=Willima Adair,
father=Adam Adair, doctor_name=Dr. Tom Smith, doctor_phone=1-555-555-2035},
contact_info={email=Brandon.Adair@powerschool.com}}, {id=3, local_id=4,
student_username=ag1student2, name={first_name=Corby, last_name=Adams},
demographics={gender=M, birth_date=2000-10-02,
district_entry_date=2014-10-12, projected_graduation_year=2018},
addresses={physical={street=4658 Norway Dr, city=Jackson, state_province=MS,
postal_code=39206}, mailing={street=4658 Norway Dr, city=Jackson,
state_province=MS, postal_code=39206}}, alerts={legal={description=Lives
with family friends, expires_date=NEVER_EXPIRES},
discipline={description=Not allowed in Media Center,
expires_date=NEVER_EXPIRES}, medical={description=Allergic to peanuts,
expires_date=NEVER_EXPIRES}, other={description=Needs to submit birth
certificate to office!, expires_date=NEVER_EXPIRES}},
phones={main={number=1-555-555-2892}}, school_enrollment={enroll_status=A,
enroll_status_description=Active, enroll_status_code=0, grade_level=10,
entry_date=2015-05-25, exit_date=2016-05-22, school_number=100, school_id=3,
entry_code=A1, entry_comment=promoted, full_time_equivalency={fteid=854,
name=Full Time}}, ethnicity_race={scheduling_reporting_ethnicity=B},
contact={emergency_contact_name1=Donovan Bowen,
emergency_phone1=1-555-555-6052, emergency_phone2=1-555-555-1854,
guardian_email=example143223@marketvolt.com, mother=Lori Adams, father=Jacob
Adams, doctor_name=Dr. Barbara Seidl, doctor_phone=1-555-555-3266},
contact_info={email=Corby.Adams@powerschool.com}}, {id=4, local_id=5,
student_username=ag1student4, name={first_name=Emmy, last_name=Ahlberg},
demographics={gender=F, birth_date=2000-11-21,
district_entry_date=2014-10-12, projected_graduation_year=2018},
addresses={physical={street=638 Belvedere Rd, city=Jackson,
state_province=MS, postal_code=39206, grid_location=Lat: 32.3573978, Lng:
-90.163067}, mailing={street=638 Belvedere Rd, city=Jackson,
state_province=MS, postal_code=39206}}, alerts={legal={description=Lives
with family friends, expires_date=NEVER_EXPIRES},
medical={description=Spleen injured in Rugby. No sports for six months,
expires_date=NEVER_EXPIRES}, other={description=Must take bus #4 all week.,
expires_date=NEVER_EXPIRES}}, phones={main={number=1-555-555-3558}},
school_enrollment={enroll_status=A, enroll_status_description=Active,
enroll_status_code=0, grade_level=10, entry_date=2015-05-25,
exit_date=2016-05-22, school_number=100, school_id=3, entry_code=A1,
entry_comment=promoted, full_time_equivalency={fteid=854, name=Full Time}},
ethnicity_race={scheduling_reporting_ethnicity=B},
contact={emergency_contact_name1=Nicholas Brannan,
emergency_phone1=1-555-555-6055, emergency_phone2=1-555-555-2688,
guardian_email=example80930@marketvolt.com, mother=Monica Ahlberg,
father=Kevin Ahlberg, doctor_name=Dr. Barbara Seidl,
doctor_phone=1-555-555-2035},
contact_info={email=Emmy.Ahlberg@powerschool.com}}, {id=5, local_id=6,
student_username=ag1student5, name={first_name=Andy, middle_name=G,
last_name=Aikinson}, demographics={gender=M, birth_date=1997-06-27,
projected_graduation_year=2016}, addresses={physical={street=732 Lindsey Dr,
city=Jackson, state_province=MS, postal_code=39209, grid_location=Lat:
32.3092896, Lng: -90.2372855}, mailing={street=732 Lindsey Dr, city=Jackson,
state_province=MS, postal_code=39209}},
alerts={medical={description=Allergic to Peanuts,
expires_date=NEVER_EXPIRES}}, phones={main={number=1-555-555-3552}},
school_enrollment={enroll_status=A, enroll_status_description=Active,
enroll_status_code=0, grade_level=12, entry_date=2015-05-25,
exit_date=2016-05-22, school_number=100, school_id=3, entry_code=A1,
entry_comment=promoted, full_time_equivalency={fteid=854, name=Full Time}},
ethnicity_race={scheduling_reporting_ethnicity=H},
contact={emergency_contact_name1=Joshua BergStrom,
emergency_phone1=1-555-555-2074, emergency_phone2=1-555-555-3770,
guardian_email=example15241@marketvolt.com, mother=Katie Aiello,
father=Roberto Aiello, doctor_name=Dr. Barbara Seidl,
doctor_phone=1-555-555-4557},
contact_info={email=Andy.Aikinson@powerschool.com}}, {id=6, local_id=7,
student_username=ag1student6, name={first_name=Scott, last_name=Alfonso},
demographics={gender=M, birth_date=1999-11-17,
projected_graduation_year=2017}, addresses={physical={street=246 Sunny Lane
Dr, city=Jackson, state_province=MS, postal_code=39204, grid_location=Lat:
32.273518, Lng: -90.2124748}, mailing={street=246 Sunny Lane Dr,
city=Jackson, state_province=MS, postal_code=39204}},
alerts={discipline={description=Uses inappropriate language,
expires_date=NEVER_EXPIRES}}, phones={main={number=1-555-555-2569}},
school_enrollment={enroll_status=A, enroll_status_description=Active,
enroll_status_code=0, grade_level=11, entry_date=2015-05-25,
exit_date=2016-05-22, school_number=100, school_id=3, entry_code=A1,
entry_comment=promoted, full_time_equivalency={fteid=854, name=Full Time}},
ethnicity_race={scheduling_reporting_ethnicity=C},
contact={guardian_email=example140401@marketvolt.com, mother=Christina
Allen, father=Daniel Allen, doctor_name=Dr. Wendy Jackson, MD,
doctor_phone=1-555-555-3266},
contact_info={email=Scott.Alfonso@powerschool.com}}, {id=7, local_id=8,
student_username=ag1student7, name={first_name=Victor, middle_name=C,
last_name=Allen}, demographics={gender=M, birth_date=1999-01-16,
projected_graduation_year=2017}, addresses={physical={city=Jackson,
state_province=MS, postal_code=39209}, mailing={street=1555 Burton St,
city=Jackson, state_province=MS, postal_code=39209}},
alerts={legal={description=Lives with family friends,
expires_date=NEVER_EXPIRES}, medical={description=Allergic to bee stings,
expires_date=NEVER_EXPIRES}}, phones={main={number=1-555-555-3567}},
school_enrollment={enroll_status=A, enroll_status_description=Active,
enroll_status_code=0, grade_level=11, entry_date=2015-05-25,
exit_date=2016-05-22, school_number=100, school_id=3, entry_code=A1,
entry_comment=promoted, full_time_equivalency={fteid=854, name=Full Time}},
ethnicity_race={scheduling_reporting_ethnicity=I},
contact={emergency_contact_name1=Daniel Atwood,
emergency_phone1=1-555-555-6237, emergency_phone2=1-555-555-1782,
guardian_email=example205225@marketvolt.com, mother=Mary Allan,
father=Andrew Allan, doctor_name=Dr. Robert Watson, MD,
doctor_phone=1-555-555-2655},
contact_info={email=Victor.Allen@powerschool.com}}, {id=8, local_id=9,
student_username=ag1student8, name={first_name=Alfred, middle_name=P,
last_name=Allred}, demographics={gender=M, birth_date=1999-05-02,
projected_graduation_year=2018}, addresses={physical={street=866 Serville
Dr, city=Jackson, state_province=MS, postal_code=39206, grid_location=Lat:
32.3689582, Lng: -90.156591}, mailing={street=866 Serville Dr, city=Jackson,
state_province=MS, postal_code=39206}},
alerts={discipline={description=Please be aware of this student. Thinks that
being on the football team should get him by, but Asst. Principal Zorr knows
better. Should you have any problems, please contact Asst. Principal Zorr,
expires_date=NEVER_EXPIRES}, medical={description=Diabetic - Insulin
available from nurse, expires_date=NEVER_EXPIRES}},
phones={main={number=1-555-555-2209}}, school_enrollment={enroll_status=A,
enroll_status_description=Active, enroll_status_code=0, grade_level=10,
entry_date=2015-05-25, exit_date=2016-05-22, school_number=100, school_id=3,
entry_code=A1, entry_comment=promoted, full_time_equivalency={fteid=854,
name=Full Time}}, ethnicity_race={scheduling_reporting_ethnicity=H},
contact={emergency_contact_name1=Michael Garner,
emergency_phone1=1-555-555-6071, emergency_phone2=1-555-555-2651,
guardian_email=example132972@marketvolt.com, mother=Kathryn Allred,
father=Payton Allred, doctor_name=Dr. Robert Watson, MD,
doctor_phone=1-555-555-2655},
contact_info={email=Alfred.Allred@powerschool.com}}, {id=9, local_id=10,
student_username=ag1student9, name={first_name=Christopher, middle_name=N,
last_name=Allred}, demographics={gender=M, birth_date=1999-10-21,
projected_graduation_year=2017}, addresses={physical={street=1134 Langley
Ave, city=Jackson, state_province=MS, postal_code=39204, grid_location=Lat:
32.2879721, Lng: -90.1958322}, mailing={city=Jackson, state_province=MS,
postal_code=39204}}, alerts={medical={description=allergic to homework,
expires_date=NEVER_EXPIRES}, other={description=Walks home after school.,
expires_date=NEVER_EXPIRES}}, phones={main={number=1-555-555-3555}},
school_enrollment={enroll_status=A, enroll_status_description=Active,
enroll_status_code=0, grade_level=11, entry_date=2015-05-25,
exit_date=2016-05-22, school_number=100, school_id=3, entry_code=A1,
entry_comment=promoted, full_time_equivalency={fteid=854, name=Full Time}},
ethnicity_race={scheduling_reporting_ethnicity=I},
contact={emergency_contact_name1=Eric Webber,
emergency_phone1=1-555-555-1695, emergency_contact_name2=Israel Turner,
emergency_phone2=1-555-555-3391, guardian_email=example39542@marketvolt.com,
mother=Wendy, Allred, father=August Allred, doctor_name=Dr. Tom Smith,
doctor_phone=1-555-555-2217},
contact_info={email=Christopher.Allred@powerschool.com}}, {id=10,
local_id=11, student_username=ag1student10, name={first_name=Jacee,
middle_name=L, last_name=Allred}, demographics={gender=F,
birth_date=1998-03-28, projected_graduation_year=2016},
addresses={physical={street=175 Kimbrough Dr, city=Jackson,
state_province=MS, postal_code=39204, grid_location=Lat: 32.2694115, Lng:
-90.2161041}, mailing={street=175 Kimbrough Dr, city=Jackson,
state_province=MS, postal_code=39204}}, alerts={legal={description=Dad has a
restraining order., expires_date=NEVER_EXPIRES},
discipline={description=Member of the student citizenship panel.,
expires_date=NEVER_EXPIRES}, medical={description=Prone to seizures,
expires_date=NEVER_EXPIRES}}, phones={main={number=1-555-555-1726}},
school_enrollment={enroll_status=A, enroll_status_description=Active,
enroll_status_code=0, grade_level=12, entry_date=2015-05-25,
exit_date=2016-05-22, school_number=100, school_id=3, entry_code=A1,
entry_comment=promoted, full_time_equivalency={fteid=854, name=Full Time}},
ethnicity_race={scheduling_reporting_ethnicity=H},
contact={emergency_contact_name1=Isaac Crosby,
emergency_phone1=1-555-555-6076, emergency_phone2=1-555-555-1967,
guardian_email=example239895@marketvolt.com, mother=Char Allred,
father=Willis Allred, doctor_name=Dr. Barbara Seidl,
doctor_phone=1-555-555-2035},
contact_info={email=Jacee.Allred@powerschool.com}}, {id=11, local_id=12,
student_username=ag1student11, name={first_name=Harold, last_name=Almanza},
demographics={gender=M, birth_date=1999-08-19,
projected_graduation_year=2017}, addresses={physical={street=264 Culley Dr,
city=Jackson, state_province=MS, postal_code=39206, grid_location=Lat:
32.3779072, Lng: -90.1591076}, mailing={street=264 Culley Dr, city=Jackson,
state_province=MS, postal_code=39206}}, alerts={legal={description=Lives
with family friends, expires_date=NEVER_EXPIRES},
medical={description=Allergic to Peanuts - Contact School Nurse Immediately
if ingested, expires_date=NEVER_EXPIRES}},
phones={main={number=1-555-555-3553}}, school_enrollment={enroll_status=A,
enroll_status_description=Active, enroll_status_code=0, grade_level=11,
entry_date=2015-05-25, exit_date=2016-05-22, school_number=100, school_id=3,
entry_code=A1, entry_comment=promoted, full_time_equivalency={fteid=854,
name=Full Time}}, ethnicity_race={scheduling_reporting_ethnicity=H},
contact={emergency_contact_name1=Gregory Stewart,
emergency_phone1=1-555-555-1742, emergency_phone2=1-555-555-3438,
guardian_email=example204196@marketvolt.com, mother=Rebecca Almanza,
father=Joseph Almanza, doctor_name=Dr. Robert Watson, MD,
doctor_phone=1-555-555-2655},
contact_info={email=Harold.Almanza@powerschool.com}}]}}
2016-12-19 22:09:58 ERROR o.a.c.processor.DefaultErrorHandler - Failed
delivery for (MessageId: ID-9801a7a2f745-55399-1482165586877-0-1 on
ExchangeId: ID-9801a7a2f745-55399-1482165586877-0-2). Exhausted after
delivery attempt: 1 caught: com.fasterxml.jackson.core.JsonParseException:
Unexpected character ('s' (code 115)): was expecting double-quote to start
field name
 at [Source: java.io.ByteArrayInputStream@30618594; line: 1, column: 3]

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                      
                                
Elapsed (ms)
[route1            ] [route1            ]
[http://localhost:1212/travel?restletMethods=PUT                              
] [        97]
[route1            ] [restBinding1      ] [                                              
                              
] [        42]
[route1            ] [route1            ] [direct:addStudents                            
                              
] [        43]
[route2            ] [log1              ] [log                                           
                              
] [         6]
[route2            ] [convertBodyTo1    ] [convertBodyTo[java.lang.String]               
                              
] [         1]
[route2            ] [unmarshal1        ]
[unmarshal[org.apache.camel.model.DataFormatDefinition@7550941]               
] [        36]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('s'
(code 115)): was expecting double-quote to start field name
 at [Source: java.io.ByteArrayInputStream@30618594; line: 1, column: 3]
	at
com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1581)
	at
com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:533)
	at
com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:462)
	at
com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleOddName(UTF8StreamJsonParser.java:2003)
	at
com.fasterxml.jackson.core.json.UTF8StreamJsonParser._parseName(UTF8StreamJsonParser.java:1650)
	at
com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:740)
	at
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
	at
com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
	at
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2908)
	at
org.apache.camel.component.jackson.JacksonDataFormat.unmarshal(JacksonDataFormat.java:172)
	at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
	at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
	at
org.apache.camel.component.restlet.RestletConsumer$1.handle(RestletConsumer.java:68)
	at
org.apache.camel.component.restlet.MethodBasedRouter.handle(MethodBasedRouter.java:54)
	at org.restlet.routing.Filter.doHandle(Filter.java:150)
	at org.restlet.routing.Filter.handle(Filter.java:197)
	at org.restlet.routing.Router.doHandle(Router.java:422)
	at org.restlet.routing.Router.handle(Router.java:639)
	at org.restlet.routing.Filter.doHandle(Filter.java:150)
	at org.restlet.routing.Filter.handle(Filter.java:197)
	at org.restlet.routing.Router.doHandle(Router.java:422)
	at org.restlet.routing.Router.handle(Router.java:639)
	at org.restlet.routing.Filter.doHandle(Filter.java:150)
	at
org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)
	at org.restlet.routing.Filter.handle(Filter.java:197)
	at org.restlet.routing.Filter.doHandle(Filter.java:150)
	at org.restlet.routing.Filter.handle(Filter.java:197)
	at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
	at org.restlet.Component.handle(Component.java:408)
	at org.restlet.Server.handle(Server.java:507)
	at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63)
	at
org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:143)
	at
org.restlet.engine.connector.HttpServerHelper$1.handle(HttpServerHelper.java:64)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
	at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
	at
sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
	at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
	at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2016-12-19 22:09:58 INFO  org.restlet.Component.LogService - 2016-12-19
22:09:58	0:0:0:0:0:0:0:1	-	-	1212	PUT	/travel/	-	500	4576	19945	106
http://localhost:1212	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36	-*

 



-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse
ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Json-format-disturbed-Rest-DSL-Jackson-tp5791716.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message