title: Angularjs GET http request to REST server returns 500 (Internal Server Error)
body: <p>I have a <a href="https://github.com/daniegarcia254/WebEng2014/tree/developer/553939_Lab2_REST/todo-rest-server" rel="nofollow">RESTful Web Service</a> that acts as a repository of ToDo tasks.</p>
  
  <p>On the other hand I have a <a href="https://github.com/daniegarcia254/WebEng2014/tree/developer/553939_Lab2_REST/todo-web-cli" rel="nofollow">Web Application</a> that uses that REST Server for managing the Todo repository.</p>
  
  <p>I've tried my first call from the client to the server in order to retrieve some data, but it fails.</p>
  
  <p>The code in the REST Server is as follows:</p>
  
  <pre><code>/**
   * A service that manipulates ToDo's in an repository.
   *
   */
  @Path("/todolist")
  public class ToDoWebService {
  
      /**
       * The (shared) repository object. 
       */
      @Inject
      ToDoList toDoList;
  
      /**
       * A GET /todos request should return the ToDo's repository in JSON.
       * @return a JSON representation of the ToDo's repository.
       */
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public ToDoList getToDoList() {
          return toDoList;
      }
  
  ....
  </code></pre>
  
  <p>And the client call (in <em>AngularJS</em>):</p>
  
  <pre><code>(function() {
        var app = angular.module('toDoApp', []);
  
        var API_URI = "http://localhost:8080/todolist";
  
        ....
        ....
  
        app.controller('addToDoCtrl', ['$scope', '$http', function($scope, $http){
          $scope.getToDoList = function() {
              $http.get(API_URI).
                  success(function(data) {
                      console.log(data);
                  }).
                  error(function(data, status, headers, config) {
                      console.log(status);
                      console.log(data);
                      console.log(headers);
                      console.log(config);
                  });
          };
        }]);
  ....
  ....
  })();
  </code></pre>
  
  <p>But the server always return a <strong><em>500 (Internal Server Error)</em></strong></p>
  
  <p>This call it's made when you click on the "AddToDo" tab of the web application, and you can see the result of the call in the console, the error in this case.</p>
  
  <p><strong>But the most remarkable thing is that when I change the REST Server code:</strong></p>
  
  <pre><code>    @GET
      @Produces(MediaType.TEXT_PLAIN)
      public String getToDoList() {
          return "It's me, example text";
      }
  </code></pre>
  
  <p>Then, it returns correctly the string "It's me, example text".</p>
  
  <p>I've checked the libaries included in the 
  I've checked the libaries included in the <a href="https://github.com/daniegarcia254/WebEng2014/blob/developer/553939_Lab2_REST/todo-rest-server/build.gradle" rel="nofollow">build.gradle</a> file and all the <a href="https://github.com/daniegarcia254/WebEng2014/tree/developer/553939_Lab2_REST/todo-rest-server/src/main/java/rest/todows" rel="nofollow">server classes</a> over and over again, finding no solution at all.</p>
  
  <p>This are the headers of the HTTP request-response, all seems in order, except for the error of course:</p>
  
  <pre><code>Remote Address:127.0.0.1:8080
  Request URL:http://localhost:8080/todolist
  Request Method:GET
  Status Code:500 Internal Server Error
  **Request Headers**
  Accept:application/json, text/plain, */*
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:es-ES,es;q=0.8,en;q=0.6
  Connection:keep-alive
  Host:localhost:8080
  Origin:http://localhost
  Referer:http://localhost/
  User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36
  Response Headersview source
  Access-Control-Allow-Credentials:true
  Access-Control-Allow-Headers:origin, content-type, accept, authorization
  Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS, HEAD
  Access-Control-Allow-Origin:*
  Access-Control-Max-Age:1209600
  Connection:close
  Content-Length:0
  Date:Fri, 31 Oct 2014 23:45:08 GMT
  </code></pre>
  
  <p><strong>¿Anybody who maybe know where this error could come from?</strong></p>