0

i want to communicate 2 application , in my first application i'm using a restTemplate to send a notification to the second app , that's why i need to have a Rest endpoint inside my second App . in the First App ( the one sending notification ) this is the method i use to send notification:

 public void setSomething() {
     String operation = "I'm sending you the operation ID";
     // URL to the SelectSystem App
     System.out.println("Tryin to send something to selectsystem-view");
     final String uri = "http://localhost:8080/from";
     RestTemplate restTemplate = new RestTemplate() ;
     if (operation != null) {
         restTemplate.postForObject( uri,operation, String.class);
         System.out.println("Send is done !!");
     }
}

In my second App (the one receiving)this is the class receiving the notification :

@RestController
public class NotificationReceiver {
    @RequestMapping(value = "/from", method = RequestMethod.POST)
    public ResponseEntity<String> createEmployee(@RequestBody String greeting) {
        if (greeting !=null) {
            System.out.println("The result From the other App is  :"+greeting);
        }
        return new ResponseEntity(HttpStatus.CREATED);
    }

    @RequestMapping(value = "/from",method = RequestMethod.GET)
    public void greeting() {
        System.out.println("testing the restController");
    }
}

the problem i'm having is that i can't map my RestController from the web.xml since i already have a JSF mapping , this is the jsf mapping web.xml :

<!-- Faces Servlet -->
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>modules/index.xhtml</welcome-file>
</welcome-file-list>

Any idea how to Map my RestController?

Bogdan Kobylynskyi
  • 1,150
  • 1
  • 12
  • 34
Elias
  • 89
  • 10
  • You can map multiple servlets... no problem – Kukeltje May 12 '17 at 17:27
  • the url i'm giving is already mapped by JSF with *.xhtml so i can't map another url for the rest controller – Elias May 12 '17 at 18:20
  • http://stackoverflow.com/questions/7885666/having-two-different-servlets-mapped-on-the-same-url-pattern and http://stackoverflow.com/questions/7938138/what-if-url-pattern-matches-multiple-servlets easy to find with right terms in google (hint: none of the ones you used as tags) – Kukeltje May 12 '17 at 18:35
  • But: servlet multiple url mapping – Kukeltje May 12 '17 at 18:44
  • @Kukeltje thank you the links were useful , i had a conceptual misunderstanding , now it's clear . – Elias May 15 '17 at 10:21

0 Answers0