Results 1 to 4 of 4

Thread: RestTemplate

  1. #1
    Join Date
    Jun 2012
    Posts
    19

    Default RestTemplate

    I am using the restTemplate object to post to a controller in another web app deployed on tomcat- I keep getting the following error:
    java.net.SocketException: Unexpected end of file from server

    Here is the code to post the request:

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getForObject("http://localhost:8080/myapp" + "/{message}",String.class, "mymessage");

    Here is the controller server side code:
    @RequestMapping(value = "/myapp/{message}", method = RequestMethod.GET)
    public void processMessage(@PathVariable String message){
    //TODO
    }

    Any help into what I am doing wrong?
    Thanks

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello

    Next time use code tags
    post the complete error stack trace for more details
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Jun 2012
    Posts
    19

    Default

    Quote Originally Posted by dr_pompeii View Post
    Hello

    Next time use code tags
    post the complete error stack trace for more details

    Here is the stack trace:
    org.springframework.web.client.ResourceAccessExcep tion: I/O error: Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server

    I am running the 2 web apps on tomcat 6 & just trying to make a rest call between the 2 to send data

  4. #4
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello

    If that is the complete error stack trace is not very useful

    I suggest you read the Spring Core Reference documentation about REST, your server side

    Code:
    Here is the controller server side code:
    @RequestMapping(value = "/myapp/{message}", method = RequestMethod.GET)
    public void processMessage(@PathVariable String message){
    //TODO
    }
    is not returning a server http status to the client. Something like OK 202

    Read the documentation for a better understanding.
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •