title: Unable to call API from controller in angular js
body: <p>I am trying to make a login module, using angular js, hibernate. I have made an API but i am unable to call it from Controller.</p>
  
  <p>Path URI(My server runs at 8085)
      URI = "<a href="http://localhost:8085/rmc/api/" rel="nofollow">http://localhost:8085/rmc/api/</a>";</p>
  
  <p>LoginAPI</p>
  
  <pre><code>    package com.rmc.api;
  
      import javax.ws.rs.Consumes;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  import javax.ws.rs.core.Response.Status;
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import com.rmc.bean.User;
  import com.rmc.business.service.LoginService;
  import com.rmc.resources.AppConfig;
  import com.rmc.resources.Factory;
  
  @Path("LoginAPI")
  public class LoginAPI {
      @POST
      @Produces(MediaType.APPLICATION_JSON)
      @Consumes(MediaType.APPLICATION_JSON)
      public Response getUserDetails(String dataRecieved) {
          Response returnValue = null;
          Gson gson = new GsonBuilder().create();
          User user = gson.fromJson(dataRecieved, User.class);
          LoginService loginService = Factory.createLoginService();
          try {
              User user2 = loginService.getUserDetails(user.getUserName(),
                      user.getPassword());
              String value = gson.toJson(user2);
              returnValue = Response.ok(value).build();
          } catch (Exception e) {
              User user2 = new User();
              user2.setMessage(AppConfig.PROPERTIES.getProperty(e.getMessage()));
              String value = gson.toJson(user2);
              if (e.getMessage().contains("DAO")) {
                  returnValue = Response.status(Status.SERVICE_UNAVAILABLE)
                          .entity(value).build();
              } else {
                  returnValue = Response.status(Status.BAD_REQUEST).entity(value)
                          .build();
              }
          }
          return returnValue;
      }
  }
  </code></pre>
  
  <p>COntroller</p>
  
  <pre><code>app.controller("LoginController",['$scope','$http','$location', function($scope,$http,$location) {
              $scope.adminLoginForm = {}; 
              $scope.adminLoginForm.getAdminDetails = function() {
                  try {
                      var data = angular.toJson($scope.adminLoginForm);
                      var responsePromise = $http.post(URI + "LoginAPI",data);
                  } catch (err) {
                      $scope.message = "There is some system Issue, Please contact Administrator";
                  }
                  responsePromise.success(function(dataFromServer,
                          status, headers, config) {
                      console.log(dataFromServer);
                      if(dataFromServer!=null){       
                          $location.pathname="\adminChoice.html";
                      }
                      else{
                          $scope.message=dataFromServer.message;
                      }
                  });
                  responsePromise.error(function(data, status, headers,
                          config) {
                      $scope.message = data;
                  });
              }
          }]);      
  </code></pre>
  
  <p>Error in console</p>
  
  <pre><code> angular.min.js:103 POST http://localhost:8085/rmc/api/LoginAPI 404 (Not Found)
  (anonymous function)
  @ angular.min.js:103n 
  @ angular.min.js:98g 
  @ angular.min.js:95(anonymous function) 
  @ angular.min.js:130$eval 
  @ angular.min.js:145$digest 
  @ angular.min.js:142$apply 
  @ angular.min.js:145(anonymous function) 
  @ angular.min.js:274dispatch 
  @ jquery.js:3r.handle 
  @ jquery.js:3
  </code></pre>
  
  <p>updated
  web.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0"&gt;
      &lt;display-name&gt;rmc&lt;/display-name&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
          &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
          &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
          &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
          &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
              &lt;param-value&gt;com.rmc.api&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>