Angular does not call spring rest services running on the same server

Viewed 63

I have one Java dynamic web project, in this project I have rest service and angular web application both. My index.html page is located on "WebContent" folder.

My web.xml code is below

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>GCSC</display-name>    
     <servlet>
         <servlet-name>gcsc</servlet-name>
         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
         <servlet-name>gcsc</servlet-name>
         <url-pattern>/</url-pattern>
      </servlet-mapping>      
      
      <session-config>
         <session-timeout>30</session-timeout>
      </session-config>   
      <welcome-file-list>
         <welcome-file>index.html</welcome-file>
      </welcome-file-list>     
</web-app>

My controller code is as below

@Controller
@RequestMapping(value={"/user","/services/user"})
public class LoginController {
    
    @Autowired
    private LoginService loginService;
    @Autowired
    private SessionUtil sessionUtil;        
    
    @RequestMapping(value={"/authenticate"},method=RequestMethod.POST,produces={"application/json"})
    @ResponseBody
    public UserAuthResponse checkAuthentication(HttpServletRequest request,@RequestBody UserCredentials user) throws Exception {  
}

When I start my system using 'http://localhost:9080/GCSC/' it opens the login page but the service is not being called from the ui. It gives the below error

 [WARNING ] SRVE0190E: File not found: /user/authenticate/
[ERROR   ] SRVE0777E: Exception thrown by application class 'com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service:1,605'
javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /user/authenticate/
    at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.service(DefaultExtensionProcessor.java:1605)

Can someone please help me to understand how to call the rest service from angular inside the same project.

0 Answers
Related