Git Product home page Git Product logo

Comments (10)

artembilan avatar artembilan commented on June 19, 2024

Your changes works for me. Share, please, the StackTrace

from spring-integration-samples.

 avatar commented on June 19, 2024
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unexpected end-of-input within/between OBJECT entries
 at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@2392d604; line: 1, column: 101] (through reference chain: org.springframework.integration.samples.rest.domain.EmployeeList["employee"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected end-of-input within/between OBJECT entries
 at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@2392d604; line: 1, column: 101] (through reference chain: org.springframework.integration.samples.rest.domain.EmployeeList["employee"])
    at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:228)
    at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.read(MappingJackson2HttpMessageConverter.java:220)
    at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:95)
    at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:784)
    at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:769)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:549)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:510)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:453)
    at org.springframework.integration.samples.rest.RestHttpClientTest.testGetEmployeeAsJsonPOST(RestHttpClientTest.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unexpected end-of-input within/between OBJECT entries
 at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@2392d604; line: 1, column: 101] (through reference chain: org.springframework.integration.samples.rest.domain.EmployeeList["employee"])
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:232)
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:197)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1420)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:244)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2993)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2158)
    at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:225)
    ... 37 more
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input within/between OBJECT entries
 at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@2392d604; line: 1, column: 101]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1524)
    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWS(UTF8StreamJsonParser.java:2546)
    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:708)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:235)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:227)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:204)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:525)
    at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:106)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:242)
    ... 41 more

from spring-integration-samples.

artembilan avatar artembilan commented on June 19, 2024

Looks like you changed something else, e.g. in the EmployeeSearchService

from spring-integration-samples.

 avatar commented on June 19, 2024

can you add some unit test like this and commit it thanks;

@Secured("ROLE_REST_HTTP_USER")
    public Message<EmployeeList> getEmployee(Message<?> inMessage){

        EmployeeList employeeList = new EmployeeList();
        Map<String, Object> responseHeaderMap = new HashMap<String, Object>();


        try{
            Employee expl=(Employee)inMessage.getPayload();
            employeeList.getEmployee().add(expl);
            MessageHeaders headers = inMessage.getHeaders();
            String id = (String)headers.get("employeeId");
            boolean isFound;
            if (id.equals("1")){
                employeeList.getEmployee().add(new Employee(1, "John", "Doe"));
                isFound = true;
            }else if (id.equals("2")){
                employeeList.getEmployee().add(new Employee(2, "Jane", "Doe"));
                isFound = true;
            }else if (id.equals("0")){
                employeeList.getEmployee().add(new Employee(1, "John", "Doe"));
                employeeList.getEmployee().add(new Employee(2, "Jane", "Doe"));             
                isFound = true;
            }else{              
                isFound = false;
            }           
            if (isFound){
                setReturnStatusAndMessage("0", "Success", employeeList, responseHeaderMap);
            }else{
                setReturnStatusAndMessage("2", "Employee Not Found", employeeList, responseHeaderMap);                              
            }

        }catch (Throwable e){

            setReturnStatusAndMessage("1", "System Error", employeeList, responseHeaderMap);
            logger.error("System error occured :"+e);
        }
        Message<EmployeeList> message = new GenericMessage<EmployeeList>(employeeList, responseHeaderMap);
        return message;     
    }

from spring-integration-samples.

artembilan avatar artembilan commented on June 19, 2024

Do you mean this:

 Employee expl=(Employee)inMessage.getPayload();
 employeeList.getEmployee().add(expl);

?
What is your point? Just to check that we can transfer request object to response?
Although I don't see concern to add it to the sample, but there is need to understand the goal.

Thanks

from spring-integration-samples.

 avatar commented on June 19, 2024

i want send object (json) by post method and add to list and get list (json);
when i test it .both in unit test and using rest-client plugin response in failed and empty .
when i trace see that object have in payload but return message failed.
thanks

from spring-integration-samples.

artembilan avatar artembilan commented on June 19, 2024

Strange: it works for me again:

09:50:11.714 INFO [main][org.springframework.integration.samples.rest.RestHttpClientTest] Return Status :[0]
09:50:11.715 INFO [main][org.springframework.integration.samples.rest.RestHttpClientTest] Return Status Message :[Success]
09:50:11.735 INFO [main][org.springframework.integration.samples.rest.RestHttpClientTest] {"employee":[{"employeeId":1,"fname":"ali","lname":"azizkhani"},{"employeeId":1,"fname":"John","lname":"Doe"},{"employeeId":2,"fname":"Jane","lname":"Doe"}],"returnStatus":"0","returnStatusMsg":"Success"}

Or you are using some old SAMPLES version, or I am wrong that test it against my Gradle branch.

I think we will add your tweaks to this sample, but already after we commit Gradle migration.

What might cause the issue, that I use Gradle and its Jetty pluging, but Maven sample uses Tomcat pluging.

As the conclusion: all your modifications are correct and have the right to life

from spring-integration-samples.

 avatar commented on June 19, 2024

i am using tomcat & maven

from spring-integration-samples.

 avatar commented on June 19, 2024

i think this is cause when i remove xml in negotiation and remove marshaler ;
i want to get json just why when i remove it this happen

from spring-integration-samples.

artembilan avatar artembilan commented on June 19, 2024

Well, does it say that you haven't shown entire changes to the sample?
Can you do it now?

from spring-integration-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.